Intel® C++ Compiler

icc 17.0.1 miscompiles valid C code at -O1 and above 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 -O0 small.c; ./a.out; echo $?
1
$ 
$ icc -O1 small.c; ./a.out; echo $?
0
$ 
$ cat small.c
struct
{
  int f:2;
} volatile a = { -1 };

int b = 1;

int main ()
{
  short c = 0;
  if (!(!b || a.f > 0))
    c = 1;
  return c;
}
$ 

 

icc 17.0.1 miscompiles valid C code at -Os and above 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 -O1 small.c; ./a.out; echo $?
0
$ 
$ icc -Os small.c; ./a.out; echo $?
1
$ 
$ cat small.c
char a[1];

int main ()
{
  unsigned long b = ~0;
  if (!a[0])
    b = 0;
  if (a[0])
    while (1)
      if (a[b])
        break;
  return !a[0] && b;
}
$ 

 

icc 17.0.1 miscompiles valid C code at -O1 and above 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 -O0 small.c; ./a.out
1
$ 
$ icc -O1 small.c; ./a.out
0
$ 
$ cat small.c
int printf (const char *, ...);

static long a;

int foo (int b)
{
  if (0) 
    if (1)
      return a;
  return b;
}

int main ()
{
  printf ("%d\n", foo (1));
  return 0; 
}
$ 

 

icc 17.0.1 miscompiles valid C code at -O3 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 -O2 small.c; ./a.out; echo $?
1
$ 
$ icc -O3 small.c; ./a.out; echo $?
0
$ 
$ cat small.c
short a = 1, b, c; 

void fn1 ()
{
  for (b = 5; b != -1; b -= 7)
    {
      while (c)
        c++;
      if (!b)
        return; 
    }
  a = 0;
}

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

 

icc 17.0.1 miscompiles valid C code (compiled code SIGFPE) at -O1 and above 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 -O0 small.c; ./a.out
$ 
$ icc -O1 small.c
$ ./a.out
Floating point exception (core dumped)
$ 
$ cat small.c
volatile struct S
{
  int f:4;
} b;

int a, c = 1, d; 

int main ()
{
  for (; a < 2; a++)
    {
      for (; d < 1; d++)
        b.f = 1;
      b.f = 0 % b.f - 1;
      if (!(c && b.f < 0))
        b.f = 0;
    }
  return 0; 
}
$ 

 

icc 17.0.1 miscompiles valid C code (compiled code SIGFPE) at -Os and above 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 -O1 small.c; ./a.out
$ 
$ icc -Os small.c
$ ./a.out
Floating point exception (core dumped)
$ 
$ cat small.c
struct
{
  int f0:2;
  int f1:2;
} f = {0, 1};

int a = 3, b, d;
volatile unsigned int c;
char e, g;

int main ()
{
  for (; a; a--)
    {
      char h = ~1 ^ d;
      d = b >> 0 / h;
      int j; 
      if (!(e || f.f0 > c))
        j = b;
      f.f0 = g = b = j;
    }
  return 0; 
}
$ 

 

icc 17.0.1 miscompiles valid C code (compiled code segfaults) at -Os and above 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 

$ cat small.c
struct
{
  int f0:24;
  volatile int f1;
} a = {-8, 0}, c[1];

volatile int b, g, i = -8;
int d, h;
unsigned int e;

int main ()
{
  if (!(d < 1 && a.f0 > b))
    g = a.f0;
  a.f0 = a.f0 && h;
  e = g - 5;
  b = i % e; 
  if (b < d)
    c[120].f1;
  if (h)
    while (1)
      ;
  return 0; 
}
$ 

 

icc 17.0.1 crashes on valid C code at -Os and above 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 -O1 -c small.c
$ 
$ icc -Os -c small.c
": internal error: 0_76

compilation aborted for small.c (code 4)
$ 
$ cat small.c
int a, b;

void fn1 ()
{
  int c[4] = { 3 };
  for (; b; b++)
    {
      int i;
      c[a] = b ^ i;
    }
}
$ 

 

icc 17.0.1 miscompiles valid C code at -O3 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 -O2 small.c; ./a.out; echo $?
8
$ 
$ icc -O3 small.c; ./a.out; echo $?
9
$ 
$ cat small.c
struct
{
  unsigned char f0;
} a, *b = &a, c, *e = &c;

int d, f;

int main ()
{
  for (f = 0; f < 2; f++)
    a.f0 = 0;
  for (; a.f0 != 8; a.f0 = (unsigned) a.f0 + 9)
    while (d)
      ;
  *e = *b;
  return c.f0; 
}
$ 

 

icc 17.0.1 miscompiles valid C code at -O1 and above on x86_64-linux-gnu

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Menlo; color: #000000; background-color: #ffffff}
span.s1 {font-variant-ligatures: no-common-ligatures}

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 -O0 small.c; ./a.out
$ 
$ icc -O1 small.c
$ ./a.out
Aborted (core dumped)
$ 
$ cat small.c
struct
{
  int a:2;
  int b:4;
} volatile c = { 0, 2 };

int main ()
{
  if (!(c.a < 1 && c.a < 1))
    __builtin_abort ();
  return 0; 
}
$ 

 

Subscribe to Intel® C++ Compiler