[Issue 15193] New: DIP25 (implementation): Lifetimes of temporaries tracked incorrectly
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Oct 12 03:47:56 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15193
Issue ID: 15193
Summary: DIP25 (implementation): Lifetimes of temporaries
tracked incorrectly
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: timon.gehr at gmx.ch
The following code corrupts memory.
enum N=100;
ref int[N] foo()@safe{
struct S{
int[N] x;
ref int[N] bar()return{ return x; }
}
return S().bar();
}
ref int[N] baz()@safe{ return foo(); }
void bang(ref int[N] x)@safe{ x[]=0x25BAD; }
void main()@safe{ bang(baz()); }
(Contrast this with:
ref int foo()@safe{
struct S{
int x;
ref int bar()return{ return x; }
}
S s;
return s.bar();
}
This is rejected correctly.)
--
More information about the Digitalmars-d-bugs
mailing list