[dmd-internals] runnable/sdtor.d
Brad Roberts
braddr at puremagic.com
Thu Jun 2 09:36:51 PDT 2011
On 6/2/2011 9:22 AM, Andrei Alexandrescu wrote:
> 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
I just double checked, neither gcc or g++ accept an empty default statement. Obviously dmd does.
Adding two more tests:
A51_a = 0; if (1) switch(1) { A51 a; default: } assert(A51_a == 1); // should be 0, right?
A51_a = 0; if (1) switch(1) { default: A51 a; } assert(A51_a == 1);
So.. two bugs.. oh Walter..
More information about the dmd-internals
mailing list