Forum Jump

Select Group :
Select Forum :
Sorted By :
Sort Order :
From The :
 
Thread Tools  Search this thread 
pmkenny1234
Total Points:
40
Registered User
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?
Dale Schouten (Intel)
Total Points:
1,960
Status Points:
1,460
Brown Belt
July 9, 2007 3:09 PM PDT
Rate
 
#1
It appears to be a bug. Thanks for pointing it out. An issue has been submitted and the appropriate developers are working on a fix. I'll respond here when it's fixed.

Thanks!

Dale


pmkenny1234
Total Points:
40
Registered User
July 10, 2007 10:29 AM PDT
Rate
 
#2 Reply to #1
Thank you. I'm looking forward to the fix.


Igor Levicki
Total Points:
10,865
Status Points:
10,865
Black Belt
July 15, 2007 7:04 PM PDT
Rate
 
#3 Reply to #1

This 10.0 release seems to be so bug ridden that I am surprised it is not called "alpha".

I submitted another serious bug (#438934 in case you have the priviledge to look at it) and I am still waiting for a response.

Both Intel C++ Compiler 9.1.037 and 10.0.025 generate broken code for the loop counter in the outer loop (index c) in function CalculateRebinMapping() in source file IntelCompilerBugOPENMP.cpp in the attached project.

Please check the code comments in the attachment for further details.


--------
If you find my post helpfull, please rate it and/or select it as a best answer where applies. Thank you.


 Attachments 
jimdempseyatthecove
Total Points:
36,417
Status Points:
36,417
Black Belt
July 16, 2007 2:41 PM PDT
Rate
 
#4 Reply to #3

As a work around, what if you place the declaration of c outside the for statement?

 long c=0;
 printf("Hack, c = %d/%d ", c, nColumns);
 for (c = 0; c < nColumns; c++)
 {
  printf("c = %d/%d ", c, nColumns);
...
This doesn't fix the bug but it may give you a work around.
Jim
 

--------

Blog: The Parallel Void


www.quickthreadprogramming.com


Igor Levicki
Total Points:
10,865
Status Points:
10,865
Black Belt
July 18, 2007 12:56 PM PDT
Rate
 
#5 Reply to #4

The issue I reported has finally been escalated so it is official now.

Jim thanks, I already have a workaround. I can write volatile long c and it works but at the cost of not performing any optimizations in that particular loop.

I posted here so that other developers can see that they should be more suspicious of the compiler itself if their code suddenly doesn't work as expected with Intel C++ Compiler 10.0 (and also 9.1 in this case).


--------
If you find my post helpfull, please rate it and/or select it as a best answer where applies. Thank you.


Qale (Intel)
Total Points:
2,630
Status Points:
2,130
Brown Belt
December 6, 2007 1:40 PM PST
Rate
 
#6
This issue is resolved in the latest 10.1 update. Posted on December 5, 2007.



Intel Software Network Forums Statistics

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