www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20803] New: Objects are destroyed too early with -inline


          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 puremagic.com
          Reporter: dlang-bugzilla 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()

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

May 07 2020