Using Intel ICC 18, I encountered the following bug in
int p = ((l == 0) ? 0 : (1 << l));
Here is how to reproduce:
[<snip> Intel18]$ cat main.cpp #include <iostream> int main(int, char**){ // for l = 0, 1, 2, 3, ... // we want to output the sequence // p = 0, 2, 4, 8, ... for(int l=0; l<4; l++){ int p = ((l == 0) ? 0 : (1 << l)); std::cout << p << ""; } std::cout << std::endl; return 0; } [<snip> Intel18]$ icc -v icc version 18.0.1 (gcc version 6.3.0 compatibility) [<snip> Intel18]$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=<snip> Target: x86_64-pc-linux-gnu Configured with: <snip> --disable-multilib --enable-languages=c,c++,fortran Thread model: posix gcc version 6.3.0 (GCC) [<snip> Intel18]$ icc main.cpp -o run_intel [<snip> Intel18]$ ./run_intel 1 2 4 8 [<snip> Intel18]$ g++ main.cpp -o run_gcc [<snip> Intel18]$ ./run_gcc 0 2 4 8
Workaround is to flip the if-statement:
int p = ((l > 0) ? (1 << l) : 0);
Does anyone know the "official" way of reporting such bugs?