Bug 6579 - Infinite loop with statement expressions in member initialization
Summary: Infinite loop with statement expressions in member initialization
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.0.4
: P3 normal
Target Milestone: ---
Assignee: Mark Mitchell
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2002-05-06 09:26 UTC by imz
Modified: 2003-07-25 17:33 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
cc_loop.ii.bz2 (70.50 KB, application/octet-stream)
2003-05-21 15:16 UTC, imz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description imz 2002-05-06 09:26:00 UTC
g++ works infinitely long on the code (illegal), so it has to be killed:

$ g++ -v -save-temps cc_loop.cc 
Reading specs from /usr/lib/gcc-lib/i586-alt-linux/3.0.4/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --enable-long-long --enable-cstdio=stdio --enable-clocale=generic --enable-languages=c,c++,f77,objc,java --program-suffix=-3.0.4 --enable-objc-gc --with-system-zlib --host=i586-alt-linux
Thread model: posix
gcc version 3.0.4
 /usr/lib/gcc-lib/i586-alt-linux/3.0.4/cpp0 -lang-c++ -D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=4 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i586__ -D__tune_pentium__ cc_loop.cc cc_loop.ii
GNU CPP version 3.0.4 (cpplib) (i386 Linux/ELF)
ignoring nonexistent directory "/usr/i586-alt-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/g++-v3
 /usr/include/g++-v3/i586-alt-linux
 /usr/include/g++-v3/backward
 /usr/local/include
 /usr/lib/gcc-lib/i586-alt-linux/3.0.4/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i586-alt-linux/3.0.4/cc1plus -fpreprocessed cc_loop.ii -quiet -dumpbase cc_loop.cc -version -o cc_loop.s
GNU CPP version 3.0.4 (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0.4 (i586-alt-linux)
	compiled by GNU C version 3.0.4.
cc_loop.cc:30: parse error before `)' token
cc_loop.cc:33: missing ';' before right brace
cc_loop.cc: In constructor `B::B(double, const A&, const std::string&)':
cc_loop.cc:30: parse error before `}' token
i586-alt-linux-g++: Internal error: Terminated (program cc1plus)
Please submit a full bug report.

Release:
3.0.4

Environment:
Linux 2.4.18-alt6-up #1 i686
ALT's distribution
Comment 2 imz 2002-05-06 20:33:51 UTC
From: Ivan Zakharyaschev <imz@altlinux.ru>
To: gcc-gnats@gcc.gnu.org, <nobody@gcc.gnu.org>
Cc:  
Subject: Re: c++/6579: works infinitely long
Date: Mon, 6 May 2002 20:33:51 +0400 (MSD)

 Correction:
 I imprudently described the code as illegal. In fact, it's not clear
 whether it is legel: it tries to use a legal GNU extension (braces in
 expressions). And this piece of code is compiled well when it is moved
 out from the constructor to some other place (a function body).
 
 Work-around:
 Don't use this GNU extension, use functions instead.
 
 Regards,
 Ivan Z. (the reporter)
 

Comment 3 Zack Weinberg 2002-10-21 17:28:24 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed with 3.2 and HEAD.
    Regression from 2.95 -> high priority.
Comment 4 Wolfgang Bangerth 2002-10-21 18:53:39 UTC
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-bugs@gcc.gnu.org, <gcc-gnats@gcc.gnu.org>, <imz@altlinux.ru>
Cc:  
Subject: Re: c++/6579: works infinitely long
Date: Mon, 21 Oct 2002 18:53:39 -0500 (CDT)

 A much simplified testcase for this failure is this:
 -------------------------------
 struct B
 {
     int a;
     B() : a(({ 1;}))   {};
 };
 -------------------------------
 which drives present CVS HEAD into an endless loop.
 
 Regards
   Wolfgang
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
 
 
Comment 5 Joe Buck 2002-10-22 13:53:12 UTC
From: Joe Buck <jbuck@synopsys.com>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org,
   nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/6579: Infinite loop with statement expressions in member
 initialization
Date: Tue, 22 Oct 2002 13:53:12 -0700

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6579
 
 PR's 6579 and 7679 appear to be duplicates.  The infinite loop appears 
 to be in spew.c,
 in yylex(), and is possibly related to error recovery.
 
 

Comment 6 Mark Mitchell 2002-10-22 13:54:19 UTC
Responsible-Changed-From-To: unassigned->mmitchel
Responsible-Changed-Why: Working on a fix.
Comment 7 Mark Mitchell 2002-10-22 17:31:41 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in GCC 3.2.1.
Comment 8 Mark Mitchell 2002-10-22 23:44:26 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/6579
Date: 22 Oct 2002 23:44:26 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-10-22 16:44:26
 
 Modified files:
 	gcc/cp         : ChangeLog spew.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/parse: stmtexpr3.C 
 
 Log message:
 	PR c++/6579
 	* spew.c (snarf_parenthesized_expression): New function.
 	(snarf_block): Use it.
 	
 	PR c++/6579
 	* g++.dg/parse/stmtexpr3.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3020&r2=1.3021
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/spew.c.diff?cvsroot=gcc&r1=1.73&r2=1.74
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2172&r2=1.2173
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/stmtexpr3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
 

Comment 9 Mark Mitchell 2002-10-22 23:44:26 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/6579
Date: 22 Oct 2002 23:44:26 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-10-22 16:44:26
 
 Modified files:
 	gcc/cp         : ChangeLog spew.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/g++.dg/parse: stmtexpr3.C 
 
 Log message:
 	PR c++/6579
 	* spew.c (snarf_parenthesized_expression): New function.
 	(snarf_block): Use it.
 	
 	PR c++/6579
 	* g++.dg/parse/stmtexpr3.C: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3020&r2=1.3021
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/spew.c.diff?cvsroot=gcc&r1=1.73&r2=1.74
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2172&r2=1.2173
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/stmtexpr3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1