[Issue 19244] New: betterC function return struct calling dtor (or not calling postblit)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 13 19:59:41 UTC 2018


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 at puremagic.com
          Reporter: patric.dexheimer at 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;

--


More information about the Digitalmars-d-bugs mailing list