[Issue 17429] New: scope class references inject additional delete calls

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed May 24 21:57:29 PDT 2017


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 at puremagic.com
          Reporter: code at 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

--


More information about the Digitalmars-d-bugs mailing list