-
-
Notifications
You must be signed in to change notification settings - Fork 610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analysis error on explicit case fall-through #19101
Labels
Comments
jbc.engelen (@JohanEngelen) commented on 2016-02-27T13:59:11ZDMD version = 2.070.0 |
coolfool4 commented on 2018-10-28T08:09:55ZI can't get errors nor warnings for fallthroughs except with final switches on enums (-w or -wi don't help).
Compiler versions:
- DMD64 D Compiler v2.082.0
- nightly at https://run.dlang.io/
import std.stdio;
void main() {
int x = 0;
switch (x) {
case 0:
case 1:
writeln("woot");
return;
default:
}
} |
coolfool4 commented on 2018-10-28T08:25:35ZActually I don't get fallthrough warnings for *any* switches. |
coolfool4 commented on 2018-10-28T08:28:38ZSo it seems to accept *empty* cases to fall through. I guess this is intended, then? |
razvan.nitu1305 commented on 2022-11-03T10:09:28ZWhen compiling the initial example I get:
test.d(18): Error: switch case fallthrough - use 'goto case;' if intended
This seems to have been fixed |
dkorpel commented on 2022-11-03T10:22:18Z(In reply to RazvanN from comment #5)
> When compiling the initial example I get:
>
> test.d(18): Error: switch case fallthrough - use 'goto case;' if intended
>
>
> This seems to have been fixed
The problem is that with -version=bad, it incorrectly raises an error about missing a return statement or assert(0). That's still the case.
Here's a reduced example:
```
// accepts valid
int a()
{
while (1)
{
switch (0)
{
case 0: // < implicit fallthrough
default: continue;
}
}
}
// rejects valid
int b()
{
while (1)
{
switch (0)
{
case 0: goto default; // < explicit fallthrough
default: continue;
}
}
}
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Johan Engelen (@JohanEngelen) reported this on 2016-02-27T13:10:38Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=15731
CC List
Description
The text was updated successfully, but these errors were encountered: