bearophile , dans le message (digitalmars.D.learn:29532), a écrit : > Well, I don't understand the error it gives :-) Are you able to explain it to > me? > > > import std.stdio; > void main() { > int i = 1; > switch(i) { > case 0: > writeln("case 0"); > goto default; // needed here > aLabel: > writeln("a label"); > default: > writeln("default"); > // But always falls through here > } > } > > test.d(10): Error: switch case fallthrough - use 'goto default;' if intended
If there is a goto aLabel somewhere, the program could go to line 9. Then it should fall to the default statement, but the compiler asks for an explicit fallthrough, since default is not a simple label, but something like a case statement. -- Christophe