[Issue 21140] New: [REG2.086] Error on missed stack allocation for closure for template
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 9 21:54:01 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21140
Issue ID: 21140
Summary: [REG2.086] Error on missed stack allocation for
closure for template
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: bugzilla at digitalmars.com
Filed this as a new bug report instead of reopening
https://issues.dlang.org/show_bug.cgi?id=20596
-------------------------------------------------------------
johanengelen at weka.io 2020-08-09 10:30:32 UTC writes:
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`
}
```
and:
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));
}
```
--
More information about the Digitalmars-d-bugs
mailing list