Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Meng-yuan_Huang
Beginner
73 Views

Intel C++ Compiler Has Bug!?

Jump to solution
My friend, justdemon (on telnet://ptt.cc), found a strange problem in Intel C++ Compiler.
I can reproduce this problem and I can't explain it.

The problem can be reproduced by the following three source files:
GAMER.h
Main.cpp
Refine.cpp

(You may need to include cstdlib header for correctly compiling them.)

The golden result should ouput the values:
1
1
0
0

However, if you compile these files by icpc without any option, i.e.:
icpc Main.cpp Refine.cpp

, and execute the program, you will get the stange result:
0
0
1
0

And if you want to debug it by recompiling the program by:
icpc -g Main.cpp Refine.cpp

, unfortunatelly, you will find the output result of this compilation is correct:
1
1
0
0

Thus, unfortunately, you can't use idb for debugging this program.

How to explain this strange problem?
Is this a bug of Intel C++ Compiler?
My Intel C++ Compiler version is 11.1 20100203 (Intel 64).
0 Kudos
1 Solution
JenniferJ
Moderator
73 Views
Yes, this is a bug in the compiler.

Please refer to the other thread for the latest info. Thanks for reporting and the testcase.

The work-around is to build the "buffer.cpp" with -O1.

Jennifer

View solution in original post

4 Replies
JenniferJ
Moderator
74 Views
Yes, this is a bug in the compiler.

Please refer to the other thread for the latest info. Thanks for reporting and the testcase.

The work-around is to build the "buffer.cpp" with -O1.

Jennifer

View solution in original post

Meng-yuan_Huang
Beginner
73 Views
Thank you for your assistant.
TimP
Black Belt
73 Views
I did ask this before, but as my post was dropped, I'll ask again: was -fp:source tried, in case the failure is associated with the intentional standard violations implied by default? This option removes most causes of numerical variations from strict standard compliance, with the only major disabled optimization being vector sum reductions.
Brandon_H_Intel
Employee
73 Views
I don't have anything to add to Jennifer and Tim's posts, but I thought this was really useful to point out -- by default, the compiler optimization setting is -O2, so when this poster did the following:

icpc Main.cpp Refine.cpp

The compiler effectively does:

icpc -O2 Main.cpp Refine.cpp

Now when you add -g, the default -O setting is no longer -O2, but instead is -O0. So when you build:

icpc -g Main.cpp Refine.cpp

The compiler is doing:

icpc -O0 -g Main.cpp Refine.cpp

If you are not specifying the -O setting, and want to add -g and debug the same build, you need to explictly set -O2 like so:

icpc -O2 -g Main.cpp Refine.cpp

Then you should be able to debug any problems.
Reply