| 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? | |||||
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
| 8484 users have contributed to 31619 threads and 100691 posts to date. |
|---|
| In the past 24 hours, we have 34 new thread(s) 123 new posts(s), and 181 new user(s). In the past 3 days, the most popular thread for everyone has been gemm(A,A,A) like possible? The most posts were made to gemm(A,A,A) like possible? The post with the most views is Dear Steve, excuse me for a d Please welcome our newest member monkeybrains |