www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19244] New: betterC function return struct calling dtor (or

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

          Issue ID: 19244
           Summary: betterC function return struct calling dtor (or not
                    calling postblit)
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: patric.dexheimer gmail.com

//flags: -betterC
import core.stdc.stdio;

struct T
{
    this() { printf("postblit\n") } //not called
    ~this() { printf("dtor\n"); } //called twice
}
auto build()
{
   T t;
   return t;
}
extern(C):
void main() 
{
    auto x = build;
}
//output:
//dtor
//dtor

//without -betterC dtor is called once;

--
Sep 13 2018