[Issue 14264] New: Destructor not called when struct is returned from a parenthesis-less function call

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Mar 9 03:31:56 PDT 2015


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

          Issue ID: 14264
           Summary: Destructor not called when struct is returned from a
                    parenthesis-less function call
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: dransic at gmail.com

struct Foo {
    ~this() {
        import std.stdio;
        writeln("I am destroyed");
    }
}

Foo makeFoo() {
    return Foo();
}

void main() {
    makeFoo(); // I am destroyed
    makeFoo;   // -> destructor is not called
}

--


More information about the Digitalmars-d-bugs mailing list