Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

miscompilure?

oiskuu
Beginner
279 Views
$ icc -O -fno-builtin -opt-report -opt-report-phasehlo bug.c -o exe1
HLO REPORT LOG OPENED ON Sun Jan 14 20:58:12 2007


High Level Optimizer Report (main)


High Level Optimizer Report (bazooka)

$ icc -O -fbuiltin -opt-report -opt-report-phasehlo bug.c -o exe2

HLO REPORT LOG OPENED ON Sun Jan 14 20:58:21 2007


High Level Optimizer Report (main)



Loop at line:31 memcopy(with guard) generated


Loop at line:32 memcopy(with guard) generated


High Level Optimizer Report (bazooka)



Loop at line:20 memcopy(with guard) generated

$ ./exe1
34
$ ./exe2
v@
$ cat bug.c
/*
* compile and run:
* icc-9.1.045 -O -fbuiltin bug.c
* icc-9.1.045 -O -fno-builtin bug.c
*/

#include

char str[10] = "1234567";
int pos = 4;

void bazooka(int to, int from)
{
char buf[10], *cp = buf;
if (from < pos) {
from = pos;
}
if (from < to) {
from -= pos;
to -= pos;
do {
*cp++ = str[from];
} while (++from < to);
}
*cp = '�';
fputs(buf, stdout);
}

int main(void)
{
bazooka(7,6);
bazooka(8,7);
return 0;
}

0 Kudos
2 Replies
Dale_S_Intel
Employee
279 Views

I assume you're trying to point out that you get bad results in the second case, when using -fbuiltin (the default at most opt levels). I get slightly different results, but I do see what I believe to be the same problem, so I've logged a bug in our bug tracking system. I'll post here again when I get more info or when the bug is fixed.

Thanks for pointing out the problem and providing a concise test case, that's most helpful!

Dale

0 Kudos
Dale_S_Intel
Employee
279 Views

This problem appears to be fixed in the 10.0 beta.

Dale

0 Kudos
Reply