Implicit fall through not detected (Example from lex.html)
Andre via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Mar 2 22:58:14 PST 2015
Hi,
I am little bit confused. I am copied the switch example from
lex.html
and expected that case 6 will lead to a syntax error due to the
missing
break statement. But the example compiles without error (C:>dmd
app)
I tried 3 different dmd version, also the newest beta.
Kind regards
André
import std.stdio: writeln;
void main()
{
int number;
string message;
switch (number)
{
default: // valid
throw new Exception("unknown number");
case 3: // valid
message ~= "three ";
break;
case 5: // valid
message ~= "five ";
goto case;
case 6: // ERROR: implicit fall-through
message ~= "six ";
case 1: // valid
case 2: // valid
message = "one or two";
}
}
More information about the Digitalmars-d-learn
mailing list