[Issue 17370] [scope] Escaping scope pointers possible via struct GC allocation
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Aug 22 07:40:13 PDT 2017
https://issues.dlang.org/show_bug.cgi?id=17370
ZombineDev <petar.p.kirov at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |petar.p.kirov at gmail.com
--- Comment #1 from ZombineDev <petar.p.kirov at gmail.com> ---
The issue is with only with the auto generated constructor. If you write one
yourself, you get:
void main () @safe
{
int* ptr = fwd();
assert(ptr !is null);
}
int* fwd () @safe
{
int i;
return new Struct(&i).oops;
}
struct Struct
{
int* oops;
this(int* p) @safe { oops = p; }
}
scope_bug17370.d(10): Error: reference to local variable i assigned to
non-scope parameter p calling scope_bug17370.Struct.this
--
More information about the Digitalmars-d-bugs
mailing list