Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
33 Views

icl.exe segfaults when compiling certain C99 code

It appears that the following C99 program will reliably segfault the Intel C/C++ compiler on Windows:

struct s {
  void *wibble;
  void *wobble;
};
static struct s my_struct;

int main(void)
{
  static int x;
  my_struct = (struct s){ &x };
}

I've reproduced this on multiple versions of the Intel compiler, most recently version 19 update 3. Running icl.exe produces:

Intel(R) C++ Intel(R) 64 Compiler for applications running on IA-32, Version 19.0.3.203 Build 20190206 (13:50)

To reproduce the bug, compile the above program with:

icl /Qstd=c99 main.c

The output is:

icl /Qstd=c99 main.c
Intel(R) C++ Intel(R) 64 Compiler for applications running on IA-32, Version 19.0.3.203 Build 20190206
Copyright (C) 1985-2019 Intel Corporation.  All rights reserved.

main.c
": internal error: ** The compiler has encountered an unexpected problem.
** Segmentation violation signal raised. **
Access violation or stack overflow. Please contact Intel Support for assistance.

compilation aborted for main.c (code 4)

This bug also seems to occur if the target is 64-bit, and I've also reproduced the bug in version 18 update 3. From testing the various Intel compiler versions available on https://godbolt.org/, it seems that the code compiles on version 13.0.1, but fails on 16.0.3, 17.0.0, 18.0.0, 19.0.0, and 19.0.1.

From briefly experimenting with this program, it seems that the crash only occurs if x is declared static here, and it is also important that there is a member following 'wibble', although it need not be a pointer. It does not seem to matter what the lvalue is for the struct assignment (it can be a dereferenced pointer, for example).

0 Kudos
3 Replies
Highlighted
Moderator
33 Views

Thank for report this problem. I've reported it to our Developer with internal #CMPLRIL0-31302

0 Kudos
Highlighted
Moderator
33 Views

Can you have this as a workaround?

 

orcsle147:/tmp$ icc -std=c99 t.c -c
orcsle147:/tmp$ cat t.c
struct s {
  void *wibble;
  void *wobble;
};
static struct s my_struct;

int main(void)
{
   static int x;
   void* tmp = &x;
   my_struct = (struct s) { tmp };

}
 

0 Kudos
Beginner
33 Views

Yes, I can trivially work around the bug, but I thought it was worth reporting since clearly the compiler shouldn't segfault on this input.

Many thanks,

Alex

0 Kudos