www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17429] New: scope class references inject additional delete

https://issues.dlang.org/show_bug.cgi?id=17429

          Issue ID: 17429
           Summary: scope class references inject additional delete calls
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

cat > bug.d << CODE
class Klazz
{
    __gshared size_t count;
    ~this()
    {
        ++count;
    }
}

void main()
{
    auto s = new Klazz;
    {
        scope s2 = s; // calls delete even though it does not own s
    }
    assert(Klazz.count == 0);
}
CODE
dmd -run bug

--
May 24 2017