[Issue 14352] New: SDC test0075.d fails under against DMD
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Mar 28 08:58:48 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14352
Issue ID: 14352
Summary: SDC test0075.d fails under against DMD
Product: D
Version: unspecified
Hardware: x86
OS: Mac OS X
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: shammah.chancellor at gmail.com
This compiles and works properly under SDC. However, when ran against DMD the
assertions fail. It appears as if "goto case" is not working correctly in DMD
based on what I can see.
```test0075.d
//T compiles:yes
//T has-passed:yes
//T retval:0
//? desc:Test goto case multiple cases in case list.
int transmogrify(int input) {
int output = 0;
switch (input) {
case 0, 1:
if (input == 0)
goto case;
else
output++;
goto case;
case 2:
output += 5;
goto case;
case 3:
output += 5;
break;
case 4, 5, 6:
goto default;
case 7:
case 8:
output += 20;
break;
default:
return -1;
}
return output;
}
int main() {
bool defaultRan = false;
switch(0) {
default:
defaultRan = true;
break;
case 0:
goto default;
}
assert(defaultRan);
assert(transmogrify(0) == 10);
assert(transmogrify(1) == 11);
assert(transmogrify(2) == 10);
assert(transmogrify(3) == 5);
assert(transmogrify(7) == 20);
assert(transmogrify(8) == 20);
assert(transmogrify(4) == -1);
assert(transmogrify(5) == -1);
assert(transmogrify(6) == -1);
assert(transmogrify(128) == -1);
return 0;
}
```
--
More information about the Digitalmars-d-bugs
mailing list