[Issue 18953] New: Win32: extern(C++) struct destructor not called correctly through runtime

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 7 05:45:54 UTC 2018


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

          Issue ID: 18953
           Summary: Win32: extern(C++) struct destructor not called
                    correctly through runtime
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: r.sagitario at gmx.de

import core.stdc.stdio;

extern(C++) 
struct S
{
        int x;
        ~this() { printf("~S %x\n", x); }
}

void main()
{
        S[] arr = new S[3];
        arr[1].x = 1;
        arr[2].x = 2;
        arr.length = 1;
        assumeSafeAppend(arr); // destroys arr[1] and arr[2]
        printf("done\n"); // arr[0] destroyed by final GC later
}

The expected output is:

~S 2
~S 1
done
~S 0

Works for win64, but for win32 (both -m32 and -m32mscoff) I get 

~S c0b831ff
~S c0b831ff
done
~S c0b831ff

--


More information about the Digitalmars-d-bugs mailing list