Jump to page: 1 2
Thread overview
[Issue 20596] [REG2.086] Error on missed stack allocation for closure for template
Apr 04, 2020
Walter Bright
Apr 05, 2020
Walter Bright
Apr 05, 2020
Dlang Bot
Apr 06, 2020
Walter Bright
Apr 14, 2020
Dlang Bot
Aug 09, 2020
Walter Bright
Aug 09, 2020
Walter Bright
Aug 09, 2020
Walter Bright
February 22, 2020
https://issues.dlang.org/show_bug.cgi?id=20596

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry, rejects-valid

--
February 22, 2020
https://issues.dlang.org/show_bug.cgi?id=20596

--- Comment #1 from johanengelen@weka.io ---
Extra note: the error is only triggered if the delegate is defined in an @nogc function. Without @nogc, this is a silent performance regression (or worse).

--
February 22, 2020
https://issues.dlang.org/show_bug.cgi?id=20596

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |performance

--
April 04, 2020
https://issues.dlang.org/show_bug.cgi?id=20596

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
Minimal test case:

 struct S(T) {
    void delegate() dg;

    this(scope void delegate() dg)
    {
        this.dg = dg;
    }
 }

 @nogc void fooTemplate() {
    int num;

    void foo() { int dummy = num; }

    scope s = S!int(&foo);
 }

--
April 05, 2020
https://issues.dlang.org/show_bug.cgi?id=20596

--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> ---
Here's the problem. There were two PRs:

https://github.com/dlang/dmd/pull/8504

which extended checking of addressing of delegates to constructor calls with the line in expressionsem.d:

     if (global.params.vsafe && checkConstructorEscape(sc, cx, false))
          return setError();

which winds up calling the line in escape.d:

     if (va && va.isScope() && fd.tookAddressOf && global.params.vsafe)
          --fd.tookAddressOf;

added by PR:

     https://github.com/dlang/dmd/pull/7981

which when combined produces the regression. The regression goes away when the two checks for global.params.vsafe (i.e. dip1000) are removed. The message did not appear before because constructor calls were not checked for escaping arguments.

--
April 05, 2020
https://issues.dlang.org/show_bug.cgi?id=20596

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #11006 "fix Issue 20596 - [REG2.086] Error on missed stack allocation for clo…" fixing this issue:

- fix Issue 20596 - [REG2.086] Error on missed stack allocation for closure for template

https://github.com/dlang/dmd/pull/11006

--
April 06, 2020
https://issues.dlang.org/show_bug.cgi?id=20596

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=20597

--
April 14, 2020
https://issues.dlang.org/show_bug.cgi?id=20596

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #11006 "fix Issues 20596, 20967 - [REG2.086] Error on missed stack allocation for clo…" was merged into master:

- 3d746b956b85d07646fe901d5e705306ab5027b9 by Walter Bright:
  fix Issues 20596, 20597 - Error on missed stack allocation for closure for
template

https://github.com/dlang/dmd/pull/11006

--
August 09, 2020
https://issues.dlang.org/show_bug.cgi?id=20596

johanengelen@weka.io changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #6 from johanengelen@weka.io ---
Reopening, because the regression is not entirely fixed.
See this slightly modified testcase, where variable `s` is not explicitly
marked `scoped`. The compiler does not deduce `scope` for `s`. This used to
compile and not GC-allocate (<= 2.085) but no longer does.

```
 struct S(T) {
    void delegate() dg;

    this(scope void delegate() dg)
    {
        this.dg = dg;
    }
 }

 @nogc void fooTemplate() {
    int num;

    void foo() { int dummy = num; }

    auto s = S!int(&foo); // not explicitly defined as `scope`
 }
```

--
August 09, 2020
https://issues.dlang.org/show_bug.cgi?id=20596

--- Comment #7 from johanengelen@weka.io ---
Another example that fails compilation:

```
struct S(T) {
    void delegate() dg;

    this(scope void delegate() dg)
    {
        this.dg = dg;
    }
 }

// The explicit `scope` here is not used in `fooTemplate`
@nogc auto dosomething(scope S!int s)
{

}

@nogc auto fooTemplate() {
    int num;

    void foo() { int dummy = num; }

    dosomething(S!int(&foo));
}
```

--
« First   ‹ Prev
1 2