Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Zhendong_Su
Beginner
135 Views

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

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
135 Views

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

Igor_V_Intel
Employee
135 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.

Zhendong_Su
Beginner
135 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. 

 

sergei_v_
Beginner
135 Views

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

Reply