[Issue 20596] New: [REG2.086] Error on missed stack allocation for closure for template
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Feb 22 22:07:22 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20596
Issue ID: 20596
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: johanengelen at weka.io
The following code used to compile but does not compile with DMD >= 2.086.1
File closuregc.d:
```
struct S
{
void delegate() @nogc dg;
@nogc this(scope void delegate() @nogc dg)
{
this.dg = dg;
}
}
@nogc void foo()
{
int num;
scope s = S(() @nogc { auto dummy = num; }); // No error.
}
struct STemplate(T)
{
void delegate() @nogc dg;
@nogc this(scope void delegate() @nogc dg)
{
this.dg = dg;
}
}
@nogc void fooTemplate()
{
int num;
scope s = STemplate!int(() @nogc { auto dummy = num; });
// closuregc.d(27): Error: function closuregc.fooTemplate is @nogc yet
allocates closures with the GC
// closuregc.d(30): closuregc.fooTemplate.__lambda1 closes over variable
num at closuregc.d(29)
}
```
Compilation with -dip1000 does work, but without it it no longer works.
Note that the error only happens for the templated case. For the non-templated
struct, there is no problem.
--
More information about the Digitalmars-d-bugs
mailing list