- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using intel c++ compiler 12.0, and working on a program similar to the following, which is very simple and straightforward. The while loop should stop in the first run. However, when I build the code using /O2 flag with the intel compiler, the while loop never stops. If I disable the optimization, or use visual c++, the loop exits normally. If I change pt->flag to p.flag, which I suppose is the same thing, the loop exits normally too. I think it has something to do with intel's optimization. Is this a bug in the intel compiler? or I missed something here?
#include <iostream>
using namespace std;
struct para {
int i;
int flag;
};
int main(int argc, char **argv)
{
para p;
p.i = 0;
p.flag = 1;
para * pt = &p;
cout << "loop started" << endl;
int i;
while (p.flag) {
if (p.i == 0) {
for (i=0; i<1; i++) {
if (p.flag != 1)
break;
}
if (i==1) {
pt->flag = 0;
}
}
}
cout << "loop stopped" << endl;
return 1;
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dan,
This issue is fixed in update 3 (and 2). Could you please upgrade to latest version to have a try. Let me know if you can reproduce the issue still.
#source /opt/intel/composer_xe_2013.1.117/bin/compilervars.sh intel64
#icc temp.cpp && ./a.out
loop started
^C
#source /opt/intel/composer_xe_2013.3.163/bin/compilervars.sh intel64
#icc temp.cpp && ./a.out
loop started
loop stopped
#
Thanks,
Shenghong

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page