Should the 2.054 feature about warning on implicit fallthrough include labels?
Timon Gehr
timon.gehr at gmx.ch
Wed Sep 14 12:31:12 PDT 2011
On 09/14/2011 08:52 PM, simendsjo wrote:
> Not sure if this is a bug or as intended.
>
> import std.stdio;
> void main() {
> int i = 1;
> switch(i) {
> case 0:
> writeln("case 0");
> goto default; // needed here
> default:
> writeln("default");
> // But always falls through here
> aLabel:
> writeln("a label");
> }
> }
This is as intended. Labels and case/default statements are not the same
thing. As an example, case/default statements introduce a new scope,
while labels do not.
More information about the Digitalmars-d-learn
mailing list