https://issues.dlang.org/show_bug.cgi?id=20803
Issue ID: 20803
Summary: Objects are destroyed too early with -inline
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: wrong-code
Severity: critical
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
//////////////// test.d ////////////////
struct V
{
bool alive = true;
void checkAlive() { assert(alive); }
}
struct S
{
V v;
@disable this(this);
~this() { v.alive = false; }
}
void main()
{
S().v.checkAlive();
}
////////////////////////////////////////
Works fine without -inline, assert trips with -inline.
This affects std.typecons.RefCounted. Because this bug causes it to return a
dangling pointer into manually-allocated memory, it can cause memory
corruption.
--