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

icc 17.0.1 miscompiles valid C code at -O2 (only) on x86_64-linux-gnu

Zhendong_Su
Beginner
767 Views

Compiler version and platform: 

Intel(R) C Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 17.0.1.132 Build 20161005 

$ icc -Os small.c; ./a.out
$ icc -O3 small.c; ./a.out
$ 
$ icc -O2 small.c  
$ ./a.out
Segmentation fault (core dumped)
$ 
$ cat small.c
int a, *b, c, d;

int fn1 ()
{
  int e = 0; 
  for (; e < 4; e++)
    if (d && *b)
      break;
  if (e & a)
    while (1)
      ;
  return c;
}

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

 

0 Kudos
4 Replies
Igor_V_Intel
Employee
767 Views

I escalated this bug to the developers (DPD200416561). Looks like it happens due to bug in vectorizer.

0 Kudos
Igor_V_Intel
Employee
767 Views

The pointer b is initialized to the correct null pointer value, however, we can't access an object using * operator. There is a bug in the code.

0 Kudos
Zhendong_Su
Beginner
767 Views

Igor, no, the code is valid because d = 0 and && has short-circuiting semantics, so *d won't be executed.  It is an ICC miscompilation bug. 

 

0 Kudos
sergei_v_
Beginner
767 Views

I confirm the same Segmentation fault happens with my installation of icc.

0 Kudos
Reply