[Issue 23440] closure over typesafe variadic or scope array passes safe though leads to stack corruption
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Mar 28 14:51:12 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23440
Steven Schveighoffer <schveiguy at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
--- Comment #2 from Steven Schveighoffer <schveiguy at gmail.com> ---
The closure should fail to allocate, since it has to point at scope data from
the heap.
It can be reduced to this case:
```d
@safe:
auto foo(scope int *x)
{
return { return x; };
}
auto bar() {
int x = 5;
return foo(&x);
}
void smash() {
ubyte[1024] data;
}
void main()
{
import std.stdio;
auto dg = bar();
smash();
writeln(*dg());
}
```
--
More information about the Digitalmars-d-bugs
mailing list