Bug 11282

Summary: [3.3 regression] Infinite memory usage after syntax error
Product: gcc Reporter: Falk Hueffner <falk>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: critical CC: gcc-bugs, vladimir
Priority: P2 Keywords: error-recovery, ice-on-invalid-code
Version: 3.3   
Target Milestone: 3.3.1   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2003-06-22 17:09:04
Attachments: Preprocessed file which triggers infinite memory usage.

Description Falk Hueffner 2003-06-22 12:06:40 UTC
Hi,

this was reported by Lukas Ruf (ruf at rawip org) on gcc-bugs 29 May 2003,
however I can't find it in the database (or even in the list archive...?).

Test case:

struct parameter_struct_t {
  char short_option;
  char *long_option;
};

parameter_struct_t *parameters[] = {
  {
    'f';
    "from";
  };
};

% g++ --version
g++ (GCC) 3.3.1 20030619 (prerelease)
% g++ -c away.cc
away.cc:8: error: syntax error before `;' token
[killed because out of memory]

mainline says:

away.cc:8: error: expected `}'
away.cc:8: error: expected `}'
away.cc:8: error: brace-enclosed initializer used to initialize `
   parameter_struct_t*'
away.cc:9: error: expected unqualified-id
away.cc:9: error: expected `,' or `;'
away.cc:10: error: expected declaration
Comment 1 Giovanni Bajo 2003-06-22 17:09:04 UTC
Confirmed. GCC 3.3 stucks forever with the given code.
Comment 2 Vladimir Prus 2003-06-30 10:14:33 UTC
I've just run into very similiar problem. The code with cause 3.2 to produce 
error message, causes 3.3 to eat all virtual memory.  
 
g++ version is: 
 
Reading specs from /usr/lib/gcc-lib/i386-linux/3.3/specs 
Configured with: ../src/configure -v 
--enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr 
--mandir=/usr/share/man --infodir=/usr/share/info 
--with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib 
--enable-nls --without-included-gettext --enable-__cxa_atexit 
--enable-clocale=gnu --enable-debug --enable-java-gc=boehm 
--enable-java-awt=xlib --enable-objc-gc i386-linux 
Thread model: posix 
gcc version 3.3 (Debian) 
 
The complete command was: 
g++-3.3 -save-temps -x c++ -Wall -ftemplate-depth-100 -O0 -fno-inline -g  
-DDEBUG_CFG  -I"." -I".." -I"../../lib" -I"../../lib/nstl" -I"../cpp_mark" 
-I"/space/NM/boost" -I"/space/NM/boost-sandbox" 
-I"bin/gcc/debug/main-target-nm_asm_analysis" 
-I"bin/gcc/debug/main-target-nm_asm" 
-I"../cpp_mark/bin/gcc/debug/main-target-cpp_lite" -I"bin/gcc/debug" 
-I"../cpp_mark/bin/gcc/debug"  -c -o 
"bin/gcc/debug/main-target-nm_asm_analysis/instruction_instance.o"  "xxx.cpp" 
virtual memory exhausted: Cannot allocate memory 
 
The offending line from xxx.cpp file is  
        visit(const Whale::NonterminalNonsense____LiteralExpression& t); 
where there's no such class in namespace Whale. 
 
I'm attaching the preprocessed file. 
 
Comment 3 Vladimir Prus 2003-06-30 10:15:54 UTC
Created attachment 4307 [details]
Preprocessed file which triggers infinite memory usage.
Comment 5 Nathan Sidwell 2003-07-23 16:47:49 UTC
fixed the first bug for 3.3.1
2003-07-23  Nathan Sidwell  <nathan@codesourcery.com>

	PR c++/11282
	* decl.c: (reshape_init): Always advance *INITP.
Comment 6 Volker Reichelt 2003-12-08 02:47:11 UTC
Since the first bug was fixed for gcc 3.3.1, I'm closing the PR.
I opened another problem report, namely PR 13349, for the unrelated
second bug.