| Thread Tools | Search this thread |
|---|
pmkenny1234
| July 2, 2007 4:53 PM PDT ICC 10.0 generating bad switch code | ||||
I'm running into a cross-platform issue with switch code generation on version 10.0 of the C++ compiler. I don't know for sure if it exists on 9, but I don't think so. Here is a simple CPP file that demonstrates the issue: #include <stdio.h> int main(int argc, char **argv) { switch(0x7fffffff) { case 0: case 1: case 0x7fffffff: printf("caught it "); break; default: printf("default "); } return 0; } In my original code, the value going into the switch was a variable and the cases were coming from an enum. However, the issue exists in this simple case with identical results. Using 10.0.016 on Mac OS and 10.0.025 on Windows this will go to the default case with the default compiler options. It should clearly go to the 0x7fffffff case. Here are some interesting details: 1) If you change all occurances of 0x7fffffff to 0x7ffffffe, it will print "caught it" (go to the right place). 2) If you compile using -O0 (no optimizations) it will go to the right place. -O1 will exhibit the error. 3) If you remove the "case 1:" line, it will go to the right place. Can anyone shed some light on this strange error? | |||||
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
| 8293 users have contributed to 31244 threads and 99122 posts to date. |
|---|
| In the past 24 hours, we have 12 new thread(s) 15 new posts(s), and 25 new user(s). In the past 3 days, the most popular thread for everyone has been huge pages on linux? The most posts were made to Pipeline buffer between stages? The post with the most views is Another example attached (Tr Please welcome our newest member bwillems |