[dmd-internals] runnable/sdtor.d

Andrei Alexandrescu andrei at erdani.com
Thu Jun 2 09:22:00 PDT 2011


On 6/2/11 11:04 AM, Brad Roberts wrote:
> So, is d (and thus dmd) supposed to deal with that case better?  I assume no since there's no case 1:, and that the test
> should be changed to:
>    if (0) switch(1) { A51 a; default: }

In this case a should never be destroyed even on if (1) as no control 
flow reaches it.

(On another vein, I'm surprised that that ever compiled. In C and C++ I 
recall it's illegal to have a label followed by no code.)

> Of course, the opposite is also interesting in terms of 'in what cases is a actually constructed/destructed':
>    if (0) switch(1) { default: A51 a; }

Diff looks good to me, and the last line should indeed call two destructors.


Andrei


More information about the dmd-internals mailing list