From: http://forum.dlang.org/post/joevwhpphvzvuijqazbi@forum.dlang.org void trySwitch(int x) { import std.stdio : writeln; SWITCH: final switch (x) { static foreach (y; [ 1, 2, 3 ]) { case y: writeln("found"); break SWITCH; } } } void main(string[] args) { import std.conv : to; trySwitch(args.length > 1 ? to!int(args[1]) : 1); } Compilation: $ dmd -wi ./main.d ./main.d(5): Warning: statement is not reachable ./main.d(5): Warning: statement is not reachable ./main.d(5): Warning: statement is not reachable ./main.d(5): Warning: statement is not reachable
Reduced test case: int main(string[] args){ int y=0; import std.conv; switch(args[1].to!int){ { case 0: break; } enum x=0; default: y=x; } return y; }
https://github.com/dlang/dmd/pull/7120
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/e606297c9138747dc71732046547b5a19829fb05 fix Issue 17807 - Spurious dead code warnings on enum and static variables. https://github.com/dlang/dmd/commit/891b53a68f253c22b8b857ca66009d0a1df4c963 Merge pull request #7120 from tgehr/fix17807 fix Issue 17807 - Spurious dead code warnings on enum and static variables.
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/e606297c9138747dc71732046547b5a19829fb05 fix Issue 17807 - Spurious dead code warnings on enum and static variables. https://github.com/dlang/dmd/commit/891b53a68f253c22b8b857ca66009d0a1df4c963 Merge pull request #7120 from tgehr/fix17807