g++ 3.3.2/3.4 correctly report the error in the example code below, but they enter an infinite loop until physical memory is exausted. This problem does not occur with g++ 3.2.2. Details: loop.cc: """ struct A { static float b[10]; } float A::b[] = {1,2,3}; """ 0) this is on an i386 (athlon) with a stock redhat 9.0 linux install 1) for g++ 3.2.2, a normal error is reported: $ /usr/bin/g++ -v Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) $ /usr/bin/g++ -c loop.cc loop.cc:6: semicolon missing after declaration of `A' loop.cc:6: two or more data types in declaration of `b' loop.cc:6: conflicting types for `A A::b[]' loop.cc:2: previous declaration as `float A::b[10]' loop.cc:6: non-empty initializer for array of empty elements $ 2) for g++ 3.3.2, an infinite loop occurs: $ /opt/gcc-3.3.2/bin/g++ -v Reading specs from /opt/gcc-3.3.2/lib/gcc-lib/i686-pc-linux-gnu/3.3.2/specs Configured with: ../gcc-3.3.2/configure --enable-languages=c,c++,f77 -enable-concept-checks --prefix=/opt/gcc-3.3.2 Thread model: posix gcc version 3.3.2 $ /opt/gcc-3.3.2/bin/g++ -c loop.cc loop.cc:6: error: semicolon missing after declaration of `A' loop.cc:6: error: two or more data types in declaration of `b' loop.cc:6: error: conflicting types for `A A::b[]' loop.cc:2: error: previous declaration as `float A::b[10]' loop.cc:6: error: initializer for `A' must be brace-enclosed loop.cc:6: error: initializer for `A' must be brace-enclosed loop.cc:6: error: initializer for `A' must be brace-enclosed . . etc... 3) for a recent gcc 3.4 snapshot, the same infinite loop occurs: $ /opt/gcc-3.4/bin/g++ -v Reading specs from /opt/gcc-3.4/lib/gcc/i686-pc-linux-gnu/3.4/specs Configured with: ../gcc-3.4-20031015/configure --enable-languages=c,c++,f77 --prefix=/opt/gcc-3.4 --disable-checking Thread model: posix gcc version 3.4 20031015 (experimental) $ /opt/gcc-3.4/bin/g++ -c loop.cc loop.cc:6: error: two or more data types in declaration of `b' loop.cc:6: error: conflicting declaration 'A A::b[]' loop.cc:2: error: 'A::b' has a previous declaration as `float A::b[10]' loop.cc:6: error: initializer for `A' must be brace-enclosed loop.cc:6: error: initializer for `A' must be brace-enclosed loop.cc:6: error: initializer for `A' must be brace-enclosed . . etc... 4) note that when you s/A::b[]/A::b[N]/ loop.cc, then the error is only reported N times and the compiler exits normally.
Confirmed. With some luck, the loop ends after about 4 billion iterations, but who wants to wait that long? :-) Gaby, this looks diagnostics related, so I assign it to you. W.
Subject: Re: [3.3/3.4 regression] memory eating infinite loop in diagnostics "bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes: | Confirmed. With some luck, the loop ends after about 4 billion iterations, | but who wants to wait that long? :-) | | Gaby, this looks diagnostics related, so I assign it to you. Thanks! -- Gaby
This seems to be fixed. I'm not sure since I never saw this bug in the first place... t.c:1: error: missing terminating " character t.c:1: error: expected unqualified-id t.c:1: error: expected `,' or `;'
Subject: Bug 12696 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-12-17 04:45:53 Modified files: gcc : ChangeLog varasm.c gcc/cp : ChangeLog decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/init: error1.C pm3.C Log message: PR c++/12218 * varasm.c (initializer_constant_valid_p): Allow a conversion from an integral constant to an OFFSET_TYPE. PR c++/12696 * decl.c (reshape_init): Recover quickly from errors. PR c++/12218 * g++.dg/init/pm3.C: New test. PR c++/12696 * g++.dg/init/error1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.2014&r2=2.2015 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/varasm.c.diff?cvsroot=gcc&r1=1.399&r2=1.400 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3814&r2=1.3815 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1162&r2=1.1163 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3273&r2=1.3274 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/error1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/pm3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed in GCC 3.4.
Mark, this is a 3.3 regression too. Can the decl.c hunks be backported to the branch as well?
Reopening as 3.3 regression only.
Subject: Bug 12696 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: gdr@gcc.gnu.org 2003-12-26 04:06:46 Modified files: gcc/cp : ChangeLog decl.c Added files: gcc/testsuite/g++.dg/init: error1.C Log message: Backport from mainline: 2003-12-16 Mark Mitchell <mark@codesourcery.com> PR c++/12696 * decl.c (reshape_init): Recover quickly from errors. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/init/error1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.4.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.228&r2=1.3076.2.229 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.965.2.65&r2=1.965.2.66