Bug 12640 – Error inside a switch statement causes a spurious switch case fallthrough warning
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-25T01:59:00Z
Last change time
2014-04-25T11:29:24Z
Keywords
diagnostic, pull
Assigned to
andrej.mitrovich
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2014-04-25T01:59:50Z
void main() @nogc {
int[1] bar;
int x;
switch (x) {
case 0:
bar = [x];
break;
default:
}
}
DMD 2.066alpha gives this, the warning is false (a rejects-valid, you can see it removing the @nogc annotation):
test.d(6,19): Error: array literals in @nogc function main may cause GC allocation
test.d(8,9): Warning: switch case fallthrough - use 'goto default;' if intended
Comment #1 by andrej.mitrovich — 2014-04-25T08:02:13Z
This isn't really specific to @nogc, there are other cases where an error inside of a switch causes a fallthrough diagnostic.
Comment #2 by andrej.mitrovich — 2014-04-25T08:03:23Z