[Issue 17807] New: Spurious dead code warnings with static foreach
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Sep 4 19:54:33 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=17807
Issue ID: 17807
Summary: Spurious dead code warnings with static foreach
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: timon.gehr at gmx.ch
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
--
More information about the Digitalmars-d-bugs
mailing list