int x; struct gdt { unsigned a,b,c,d,e,f; }; void f() { /* workaround, int* z=&x; replace &x with z */ struct gdt gdt_table[2]= { { 0, /* the &x seems to be the problem, without it, no ICE */ ( (((unsigned)(&x))<<(24))&(-1<<(8)) ), }, }; } /* CODE ENDS */ /* gcc test2.c test2.c: In function `f': test2.c:17: internal compiler error: in copy_constant, at varasm.c:2631 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. gcc -v Reading specs from /usr/local/lib/gcc-lib/i386-unknown-freebsd4.7/3.3/specs Configured with: ./configure --prefix=/usr/local --enable-languages=java Thread model: posix gcc version 3.3 /usr/local/gcc34/bin/gcc test2.c test2.c: In function `f': test2.c:17: internal compiler error: in copy_constant, at varasm.c:2532 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. /usr/local/gcc34/bin/gcc -v Reading specs from /usr/local/gcc34/lib/gcc-lib/i386-unknown- freebsd4.7/3.4/specs Configured with: ./configure --prefix=/usr/local/gcc34 : (reconfigured) ./configure --prefix=/usr/local/gcc34 Thread model: posix gcc version 3.4 20030702 (experimental) */
I can confirm gcc ICEs on this in 2.95.3, 3.0.4, 3.2.2, 3.2.3, 3.3.1 (20030707) and the mainline (20030724) so this is not a regression.
Dunno whether the code is valid or not. C language experts?
This is valid c as the initializer does not have to be a constant when it in a function. Also this ICE on the C++ front-end too, so this is a middle-end problem, most likely related to bug 11852 (might even was fixed by it, I did not test GCC with the patch). I will tentatively put the target as 3.3.2 and I will retest it when I bootstrap with updated sources with the patch already applied.
Guess what it is fixed by the same patch which fixed bug 11852 so commiting a testcase for this one. Forgot to say this is fixed in 3.3.2 and 3.4.
*** Bug 12123 has been marked as a duplicate of this bug. ***