GCC throws an internal compiler error when compiling the following C99 code (gcc -std=c99 -c): static char * name[] = { [0x80000000] = "bar" }; (GCC reports `internal compiler error: in tree_low_cst, at tree.c:3318'.) I realize that the above code is quite stupid, as I request the compiler to create an array of huge size. However, I think GCC should not throw an internal compiler error. For smaller values of the array index, GCC correctly reports `error: size of variable 'name' is too large'. I have reproduced the problem with GCC 3.4.4 (Gentoo Linux) and GCC 3.3.5 (SuSE 9.3), both on Intel Pentium M.
Confirmed. This is only reproducible on targets where HOST_WIDE_INT is 32bits (and I still say that HOST_WIDE_INT should be always at least 64bits). Oh and this is a regression for at least x86.
HOST_WIDE_INT is what it says. The code should check host_integerp first and then use TREE_INT_CST_LOW.
: Search converges between 2002-02-17-trunk (#59) and 2002-02-24-trunk (#60).
Hmm, I almost want to say this was caused by: 2002-02-20 Roger Sayle <roger@eyesopen.com> Jakub Jelinek <jakub@redhat.com> PR c/4389 * tree.c (host_integerp): Ensure that the constant integer is representable in a HOST_WIDE_INT or an unsigned HOST_WIDE_INT when pos is zero or nonzero respectively. Clarify comment. * c-format.c (check_format_info_recurse): Fix host_integerp usage; the pos argument should be zero when assigning to a signed HOST_WIDE_INT. Which means it was a latent bug as this added the ICE in the first place.
ICE on somewhat odd code: P2.
This issue will not be resolved in GCC 4.1.0; retargeted at GCC 4.1.1.
Subject: Bug 25309 Author: sayle Date: Fri Apr 28 19:59:57 2006 New Revision: 113355 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113355 Log: PR c/25309 * c-typeck.c (struct spelling): Make I an unsigned HOST_WIDE_INT. (push_array_bounds): Delete prototype. Change BOUNDS argument to an unsigned HOST_WIDE_INT. (print_spelling): Use HOST_WIDE_INT_PRINT_UNSIGNED to output the array index. (really_start_incremental_init): No need to call convert because bitsize_zero_node is already of type bitsizetype. (push_init_level): Extract the value of constructor_index as an unsigned HOST_WIDE_INT quantity, using tree_low_cst. (process_init_element): Likewise. * gcc.dg/large-size-array-2.c: New test case. Added: trunk/gcc/testsuite/gcc.dg/large-size-array-2.c Modified: trunk/gcc/ChangeLog trunk/gcc/c-typeck.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 25309 Author: sayle Date: Tue May 2 17:15:25 2006 New Revision: 113476 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113476 Log: PR c/25309 * c-typeck.c (struct spelling): Make I an unsigned HOST_WIDE_INT. (push_array_bounds): Delete prototype. Change BOUNDS argument to an unsigned HOST_WIDE_INT. (print_spelling): Use HOST_WIDE_INT_PRINT_UNSIGNED to output the array index. (really_start_incremental_init): No need to call convert because bitsize_zero_node is already of type bitsizetype. (push_init_level): Extract the value of constructor_index as an unsigned HOST_WIDE_INT quantity, using tree_low_cst. (process_init_element): Likewise. * gcc.dg/large-size-array-2.c: New test case. Added: branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/large-size-array-2.c Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/c-typeck.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Subject: Bug 25309 Author: sayle Date: Wed May 3 18:49:40 2006 New Revision: 113500 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113500 Log: PR c/25309 * c-typeck.c (struct spelling): Make I an unsigned HOST_WIDE_INT. (push_array_bounds): Delete prototype. Change BOUNDS argument to an unsigned HOST_WIDE_INT. (print_spelling): Use HOST_WIDE_INT_PRINT_UNSIGNED to output the array index. (really_start_incremental_init): No need to call convert because bitsize_zero_node is already of type bitsizetype. (push_init_level): Extract the value of constructor_index as an unsigned HOST_WIDE_INT quantity, using tree_low_cst. (process_init_element): Likewise. * gcc.dg/large-size-array-2.c: New test case. Added: branches/gcc-4_0-branch/gcc/testsuite/gcc.dg/large-size-array-2.c Modified: branches/gcc-4_0-branch/gcc/ChangeLog branches/gcc-4_0-branch/gcc/c-typeck.c branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
This should now be fixed on mainline and all active branches.
I see this error for cris-axis-elf with trunk, as late as r123034: gcc.dg/large-size-array-2.c:6: internal compiler error: in tree_low_cst, at tree.c:4867 I think the proper action is to re-open the PR, right?
Ok, I can reproduce this ICE on a cross to cris-axis-elf, why it works for powerpc-darwin and spu-elf, I don't know. Does cris normally have HOST_WIDE_INT as being 32bits?
I'm not sure I understand comment #12, because HOST_WIDE_INT is decided by the host, not the target, unless need_64bit_hwint=yes but that's *not* set for cris-*-*; it's a fairly regular 32-bit:er. I saw this with a cross from a x86_64-unknown-linux-gnu host (64-bit longs).
Working on a patch.
Subject: Bug 25309 Author: jsm28 Date: Wed Sep 26 12:32:27 2007 New Revision: 128811 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128811 Log: PR c/25309 * c-common.c (complete_array_type): Diagnose too-large arrays and set type to error_mark_node. testsuite: * gcc.dg/large-size-array-2.c: Expect diagnostic for too-large array. * gcc.dg/large-size-array-4.c: New. Copy of large-size-array-2.c without -O2. Added: trunk/gcc/testsuite/gcc.dg/large-size-array-4.c Modified: trunk/gcc/ChangeLog trunk/gcc/c-common.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/large-size-array-2.c
Fixed for 4.3.0.
Subject: Bug 25309 Author: jsm28 Date: Wed Oct 10 20:46:11 2007 New Revision: 129216 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129216 Log: PR c/25309 * c-common.c (complete_array_type): Diagnose too-large arrays and set type to error_mark_node. testsuite: * gcc.dg/large-size-array-2.c: Expect diagnostic for too-large array. * gcc.dg/large-size-array-4.c: New. Copy of large-size-array-2.c without -O2. Added: branches/gcc-4_2-branch/gcc/testsuite/gcc.dg/large-size-array-4.c Modified: branches/gcc-4_2-branch/gcc/ChangeLog branches/gcc-4_2-branch/gcc/c-common.c branches/gcc-4_2-branch/gcc/testsuite/ChangeLog branches/gcc-4_2-branch/gcc/testsuite/gcc.dg/large-size-array-2.c
Fixed for 4.2.3.
Closing 4.1 branch.