www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18953] New: Win32: extern(C++) struct destructor not called


          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 puremagic.com
          Reporter: r.sagitario gmx.de

import core.stdc.stdio;

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
~S 0

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

~S c0b831ff
~S c0b831ff
~S c0b831ff

Jun 06 2018