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

icc 17.0.0 miscompiles valid C code (compiled code hangs) at -O1 and above on x86_64-linux-gnu

Zhendong_Su
Beginner
313 Views

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.0.098 Build 20160721

$ icc -O0 small.c; ./a.out
$ 
$ icc -O1 small.c
$ timeout -s 9 10 ./a.out
Killed
$ 
$ cat small.c
volatile int b = 1;
static int c;

short fn1 ()
{
  if (1)
    return b;
  return c;
}

int fn2 ()
{
  while (1)
    if (fn1 ())
      return 2;
}

int main ()
{
  fn2 ();
  return 0; 
}
$ 

 

0 Kudos
2 Replies
Igor_V_Intel
Employee
313 Views

Reproduced with 17.0 and escalated (DPD200415574). Thanks.

0 Kudos
Zhendong_Su
Beginner
313 Views

Thanks, Igor. 

0 Kudos
Reply