[Issue 20803] New: Objects are destroyed too early with -inline
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri May 8 00:11:17 UTC 2020
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: nobody at puremagic.com
Reporter: dlang-bugzilla at thecybershadow.net
//////////////// 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.
--
More information about the Digitalmars-d-bugs
mailing list