Found a bug in the Intel compiler.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code sample illustrating a bug in the Intel compiler | |
// icpc (ICC) 13.0.1 20121010 | |
// compile with: | |
// icc -restrict -std=c99 -O2 iccbug.c -o iccbug | |
// then run iccbug | |
// Tested in Linux Ubuntu 12.10 (Intel Core i7) | |
#include <stdint.h> | |
#include <stdio.h> | |
// expect: out[0] = in[0] + in[1] + in[2] + in[3]; | |
// out[1] = in[4] + in[5] + in[6] + in[7]; | |
__attribute__((noinline)) | |
void broken_with_O2(int * restrict in, | |
int * out) { | |
for(int outer = 0; outer < 2; outer++) { | |
*out = *in++; | |
for (int inner = 1; inner < 4; inner++) { | |
*out += *in++; | |
} | |
++out; | |
} | |
} | |
int main() { | |
int in[8] = {1,1,1,1,1,1,1,1}; | |
int out[2]; | |
broken_with_O2(&in[0],&out[0]); | |
printf(" got = %d %d\n",out[0], out[1]); | |
printf(" expected = %d %d\n", 4,4); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment