On 5/3/14, 12:40 PM, Walter Bright wrote:
On 5/1/2014 7:59 AM, Andrei Alexandrescu wrote:
If a class has at least one member with a
destructor, the compiler might need to generate a destructor for the
class.

And in fact that's what dmd does.

Which suggests a simple solution for calling destructors for structs and arrays:

* Lower new for structs to return:

new S;
->
return &(new class { S member; }).member;

* Lower array construction similarly.

Then voila, the anonymous classes will destroy structs and arrays appropriately.


Andrei

Reply via email to