Bug 431 – Invalid case selected when switching on a long
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-10-12T15:21:00Z
Last change time
2014-02-15T13:20:21Z
Keywords
wrong-code
Assigned to
bugzilla
Creator
h3r3tic
Comments
Comment #0 by h3r3tic — 2006-10-12T15:21:19Z
void main() {
long foo = 4;
switch (foo) {
case 2: assert (false); break;
case 3: break;
case 4: break;
case 5: break;
}
}
// Error: AssertError Failure switchbug.d(4)
Comment #1 by braddr — 2006-10-16T04:41:43Z
I'm unable to reproduce this on linux with dmd recent versions of dmd (166-169). That points to a windows specific bug. To confirm that case 4 was being taken, I altered the test case to:
$ cat -n 431.d
1 void main() {
2 long foo = 4;
3 switch (foo) {
4 case 2: assert (false, "2"); break;
5 case 3: assert (false, "3"); break;
6 case 4: assert (false, "4"); break;
7 case 5: assert (false, "5"); break;
8 }
9 }
$ ./431
Error: AssertError Failure 431.d(6) 4
Before that alteration, it'd run without error.