The following invalid code snippet causes an ICE since GCC 4.0.3: =================================== struct A { static const int i = j; int x[i]; }; =================================== bug.cc:3: error: 'j' was not declared in this scope bug.cc:4: internal compiler error: in size_binop, at fold-const.c:1736 Please submit a full bug report, [etc.]
Confirmed.
Testing a patch.
Subject: Bug number PR27384 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-05/msg00443.html
Subject: Bug 27384 Author: reichelt Date: Thu May 11 15:07:45 2006 New Revision: 113701 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113701 Log: PR middle-end/27384 * fold-const.c (size_binop): Move sanity check for arguments to the beginning of the function. * g++.dg/other/fold1.C: New test. Added: trunk/gcc/testsuite/g++.dg/other/fold1.C Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 27384 Author: reichelt Date: Thu May 11 15:11:50 2006 New Revision: 113702 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113702 Log: PR middle-end/27384 * fold-const.c (size_binop): Move sanity check for arguments to the beginning of the function. * g++.dg/other/fold1.C: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/g++.dg/other/fold1.C Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/fold-const.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Subject: Bug 27384 Author: reichelt Date: Thu May 11 15:16:49 2006 New Revision: 113703 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113703 Log: PR middle-end/27384 * fold-const.c (size_binop): Move sanity check for arguments to the beginning of the function. * g++.dg/other/fold1.C: New test. Added: branches/gcc-4_0-branch/gcc/testsuite/g++.dg/other/fold1.C Modified: branches/gcc-4_0-branch/gcc/ChangeLog branches/gcc-4_0-branch/gcc/fold-const.c branches/gcc-4_0-branch/gcc/testsuite/ChangeLog
Fixed on mainline, 4.1 branch, and 4.0 branch.