www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14264] New: Destructor not called when struct is returned

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 puremagic.com
          Reporter: dransic 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
}

--
Mar 09 2015