From: Matt H. <ma...@cs...> - 2006-01-10 03:07:17
|
Hi, A missing initializer for a global variable means that the compiler should initialize that value to zero. So the two initializers are equivalent. If your analysis needs to see explictly that the fourth element of foo is initialized to {0,0}, you can use foldLeftCompoundAll. -- Matt _____ From: cil...@li... [mailto:cil...@li...] On Behalf Of hongruan Sent: Monday, January 09, 2006 1:08 AM To: Bug report for cil; cil-mail-list Subject: [CIL users] Incorrect translation of static variable initialisation I try to compile the following code using CIL: ----------------test2.c start ---------------- struct foo{ unsigned long a; unsigned long b; }; static struct foo foos[]={ {1,0}, {2,0}, {3,0}, {}, }; int main(void) { return 0; } ----------------test2.c end ------------------ The commands I used are the following: ---------------------------------------------- $gcc -E test2.c -o test2.i $cilly.asm.exe --keepunused --out test2.cil.c test2.i $gcc -c test2.cil.c -o test2.i ---------------------------------------------- But the context of the test2.cil.c is the following: --------------test2.cil.c start--------------------- /* Generated by CIL v. 1.3.4 */ /* print_CIL_Input is true */ #line 1 "test2.c" struct foo { unsigned long a ; unsigned long b ; }; #line 6 "test2.c" static struct foo foos[3] = { {1UL, 0UL}, {2UL, 0UL}, {3UL, 0UL}}; #line 13 "test2.c" int main(void) { { #line 16 return (0); } } --------------test2.cil.c end----------------------- BUT I think the result of struct foo foos[] should be translated into the following: ---------------------------------------------------- #line 6 "test2.c" static struct foo foos[4] = { {1UL, 0UL}, {2UL, 0UL}, {3UL, 0UL} {0UL, 0UL}}; ---------------------------------------------------- Maybe It is a bug about CIL. Thanks a lot! Camelguo |