[Issue 22977] [dip1000] can escape scope pointer returned by nested function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Aug 27 21:24:58 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22977
--- Comment #3 from Walter Bright <bugzilla at digitalmars.com> ---
Interestingly, if `scope return` is added to `fn()`:
int* gPtr;
void main() @safe
{
scope int* sPtr;
int* fn() scope return { return sPtr; }
gPtr = fn();
}
The correct error is generated:
Error: reference to stack allocated value returned by `fn()` assigned to
non-scope `gPtr`
--
More information about the Digitalmars-d-bugs
mailing list