https://issues.dlang.org/show_bug.cgi?id=15009
Kenji Hara <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Object.destroy doesn't call |Object.destroy calls |dtors for object in static |unnecessary postblits for |arrays |destruction of static | |arrays object --- Comment #2 from Kenji Hara <[email protected]> --- Note that, destroy actually calls destructors. import std.stdio, std.conv, core.stdc.stdlib; struct S { int x; this(int x) { writeln("ctor"); } this(this) { writeln("ctor(postblit)"); } ~this() { writeln("dtor"); } } void main(string[] args) { S[2]* arr = cast(S[2]*)calloc(1, S.sizeof); printf("-- calloc done\n"); emplace(arr, S(1)); printf("-- emplace done\n"); destroy(*arr); printf("-- destroy done\n"); //typeid(*arr).destroy(&arr); free(arr); printf("-- free done\n"); } output is: $ dmd -run test -- calloc done ctor ctor(postblit) ctor(postblit) dtor -- emplace done ctor(postblit) dtor ctor(postblit) dtor -- destroy done -- free done My point is , the two postblit calls invoked by destroy() is unnecessary. --
