[Issue 22298] New: [DIP1000] Nested function's scope parameters can be assigned to variables in enclosing function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Sep 10 21:16:45 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22298
Issue ID: 22298
Summary: [DIP1000] Nested function's scope parameters can be
assigned to variables in enclosing function
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: giacomo.ratto at protonmail.com
This makes possible to get a pointer to a local variable within an expired
stack frame:
---
void g(scope void delegate(scope int*) @safe cb) @safe {
int x = 42;
cb(&x);
}
void main() @safe {
int* p;
void f(scope int* i) @safe {
p = i;
}
g(&f);
// address of x has escaped g
assert(*p == 42);
}
---
--
More information about the Digitalmars-d-bugs
mailing list