A testcase that has an array larger than half the address space and smaller than the address space will trigger an abort in tree_int_cst_low. The problem here is that we have a TREE_OVERFLOW (TYPE_SIZE (...)) check in the C++ front end. This no longer works now that TYPE_SIZE is computed as bitsizetype which has extra precision. We must use TYPE_SIZE_UNIT instead. This is trivial to fix, but now the testcase gets two errors instead of the expected one error. I don't know if this is intended behaviour, or whether this is a latent bug in the C++ front end. Either way, my testcase doesn't work for the testsuite because of this problem, so a C++ front end maintainer will have to decide what to do. Result without the patch large-size-array.cc: In function ‘int main()’: large-size-array.cc:17: internal compiler error: in tree_low_cst, at tree.c:4270 Result with the patch large-size-array.cc: In function ‘int main()’: large-size-array.cc:19: error: size of array ‘a’ is too large large-size-array.cc:20: error: ‘a’ was not declared in this scope Both of these results are wrong.
Created attachment 9504 [details] Patch to partially fix problem with too large arrays.
Created attachment 9505 [details] Testcase for too large array problem.
Confirmed. A regression from 3.4.0. Note there is a typo in the test, USHORT_MAX should be USHRT_MAX.
Created attachment 9524 [details] corrected testcase for too large array problem Fix typo in testcase.
Created attachment 9525 [details] corrected patch to partially fix problem with too large arrays
*** Bug 23461 has been marked as a duplicate of this bug. ***
I think the knock-on error message is a latent bug in the C++ front end, so your patch is fine.
Subject: Bug 23426 CVSROOT: /cvs/gcc Module name: gcc Changes by: wilson@gcc.gnu.org 2005-08-22 23:56:30 Modified files: gcc/cp : ChangeLog Log message: Correct PR number in last patch checked in. PR tree-optimization/23426 * decl.c (grokdeclarator): Use TYPE_SIZE_UNIT not TYPE_SIZE for array size check. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4855&r2=1.4856
Subject: Bug 23426 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: wilson@gcc.gnu.org 2005-08-23 00:07:48 Modified files: gcc/cp : ChangeLog decl.c Log message: Partial fix for too large array problem. PR tree-optimization/23426 * decl.c (grokdeclarator): Use TYPE_SIZE_UNIT not TYPE_SIZE for array size check. Backport from mainline 2005-06-14 Roger Sayle <roger@eyesopen.com> * decl.c (grokdeclarator): Only check TREE_OVERFLOW on INTEGER_CST. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.79&r2=1.4648.2.80 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1371.2.18&r2=1.1371.2.19
I've added my patch to mainline and the gcc-4.0.x branch, but there is still the problem that my testcase generates two errors when it should only generate one.
earth:~>gcc t.cc t.cc: In function ‘int main()’: t.cc:19: error: size of array ‘a’ is too large t.cc:20: error: ‘a’ was not declared in this scope earth:~>~/ia32_linux_gcc3_4/bin/gcc t.cc t.cc: In function `int main()': t.cc:19: error: size of variable 'a' is too large earth:~>gcc -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: /home/peshtigo/pinskia/src/gnu/gcc/src/configure --target=i686-pc-linux-gnu -- host=i686-pc-linux-gnu --enable-__cxa_atexit --enable-languages=c++,objc,java,f95 --prefix=/ home/gates/pinskia/linux --enable-threads=posix --enable-shared Thread model: posix gcc version 4.1.0 20050823 (experimental) So the error message is also a regression but that makes this minor as the first error message is correct.
I might have a fix for the two error messages, though it might also cause other issues, let see what happens in the test results.
(In reply to comment #12) > I might have a fix for the two error messages, though it might also cause other > issues, let see what happens in the test results. It did not work.
Actually I figured out how to fix the problem with my patch, just moving around error mark node is what is needed here.
Patch posted: http://gcc.gnu.org/ml/gcc-patches/2005-10/msg01599.html
Subject: Bug 23426 Author: pinskia Date: Fri Oct 28 14:50:53 2005 New Revision: 105934 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=105934 Log: 2005-10-28 Andrew Pinski <pinskia@physics.uc.edu> PR C++/23426 * decl.c (start_decl): Check that the decl is an error_mark_node before getting the type. Remove the check for the decl's type being an error_mark_node. 2005-10-28 Andrew Pinski <pinskia@physics.uc.edu> PR C++/23426 * g++.dg/other/large-size-array.C: New test. Added: branches/gcc-4_0-branch/gcc/testsuite/g++.dg/other/large-size-array.C Modified: branches/gcc-4_0-branch/gcc/ChangeLog branches/gcc-4_0-branch/gcc/cp/decl.c branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
Subject: Bug 23426 Author: pinskia Date: Fri Oct 28 14:57:30 2005 New Revision: 105936 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=105936 Log: 2005-10-28 Andrew Pinski <pinskia@physics.uc.edu> PR C++/23426 * decl.c (start_decl): Check that the decl is an error_mark_node before getting the type. Remove the check for the decl's type being an error_mark_node. 2005-10-28 Andrew Pinski <pinskia@physics.uc.edu> PR C++/23426 * g++.dg/other/large-size-array.C: New test. Added: trunk/gcc/testsuite/g++.dg/other/large-size-array.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Fixed in 4.0.3.