[Issue 23445] New: Can leak scope variable through delegate context
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Oct 30 20:40:10 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23445
Issue ID: 23445
Summary: Can leak scope variable through delegate context
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: accepts-invalid, safe
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: timon.gehr at gmx.ch
With DMD v2.101.0-beta.1, the following code is accepted:
int global;
int* foo(scope int* p)@safe{
auto dg=(return scope int* q)@safe return scope{
return p;
};
return dg(&global);
}
auto qux()@safe{
int x=10;
int* p=&x;
int* q=foo(p);
return q;
}
void main()@safe{
import std.stdio;
auto p=qux();
version(SMASH_STACK) writeln("smashing stack");
writeln(*p);
}
--
More information about the Digitalmars-d-bugs
mailing list