From runnable/sdtor.d, test 51:
int A51_a;
struct A51
{
~this() { ++A51_a; }
}
void test51() // an excerpt from the full test
{
// should fail to build, no case 1 and no default
A51_a = 0; { if (0) final switch(1) A51 a; } assert(A51_a == 0);
// should be 0, there's no flow that should involve a being instantiated
// or destroyed
A51_a = 0; { if (1) switch(1) { A51 a; default: } } assert(A51_a == 1);
}
Comment #1 by dlang-bugzilla — 2017-07-05T16:05:57Z
(In reply to Brad Roberts from comment #0)
> // should be 0, there's no flow that should involve a being instantiated
> // or destroyed
> A51_a = 0; { if (1) switch(1) { A51 a; default: } } assert(A51_a == 1);
This is now a deprecation (since https://github.com/dlang/dmd/pull/5869).
Comment #2 by robert.schadek — 2024-12-13T17:55:26Z