cil-project / cil

C Intermediate Language
Other
348 stars 86 forks source link

"Initializing non-constant-length array" error when parsing a correct C file. #45

Open ehboudjema opened 6 years ago

ehboudjema commented 6 years ago

I have the error : Error: Initializing non-constant-length array with the following C code :

typedef enum { A = 0, B = 1 } Enum;

int main (){ char arr[((Enum)1)] = "a"; printf("%s\n",arr); }

The code above compiles and runs correctly using GCC.

pmetzger commented 6 years ago

Which line is it saying is the error? You haven't specified that.

ehboudjema commented 6 years ago

It is on line 8: char arr[((Enum)1)] = "a";

pmetzger commented 6 years ago

The code is a little weird, but it should parse because it is indeed a constant. I would recommend trying to figure out what the bug is by diving in to the code, it's the only way you're going to get it fixed.