a nested copy constructor with unclosed parentheses, if nested sufficiently deeply, exhausts memory and kills the compiler after several minutes of churning.
class C; C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C( // (40 nested unclosed constructor parentheses) in the syntactically correct case, the compile finishes in less than one second. class C; C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C()))))))))))))))))))))))))))))))))))))))); i've tested on both RedHat FC7 and Solaris 10/Intel, and the behavior is the same. below is the FC7 output. phoenix% /opt/gcc-4.4.0/bin/g++ -v -save-temps -c bug.C Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: ./configure --prefix=/opt/gcc-4.4.0 --with-mpfr=/opt/mpfr-2.4.1 Thread model: posix gcc version 4.4.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-shared-libgcc' '-mtune=generic' /opt/rw/gcc-4.4.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.4.0/cc1plus -E -quiet -v -iprefix /opt/rw/gcc-4.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/ -D_GNU_SOURCE bug.C -mtune=generic -fpch-preprocess -o bug.ii ignoring nonexistent directory "/opt/rw/gcc-4.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../x86_64-unknown-linux-gnu/include" ignoring duplicate directory "/opt/rw/gcc-4.4.0/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0" ignoring duplicate directory "/opt/rw/gcc-4.4.0/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/x86_64-unknown-linux-gnu" ignoring duplicate directory "/opt/rw/gcc-4.4.0/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/backward" ignoring duplicate directory "/opt/rw/gcc-4.4.0/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include" ignoring duplicate directory "/opt/rw/gcc-4.4.0/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include-fixed" ignoring nonexistent directory "/opt/rw/gcc-4.4.0/bin/../lib/gcc/../../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /opt/rw/gcc-4.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0 /opt/rw/gcc-4.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/x86_64-unknown-linux-gnu /opt/rw/gcc-4.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../include/c++/4.4.0/backward /opt/rw/gcc-4.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include /opt/rw/gcc-4.4.0/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include-fixed /usr/local/include /opt/rw/gcc-4.4.0/bin/../lib/gcc/../../include /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-shared-libgcc' '-mtune=generic' /opt/rw/gcc-4.4.0/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.4.0/cc1plus -fpreprocessed bug.ii -quiet -dumpbase bug.C -mtune=generic -auxbase bug -version -o bug.s GNU C++ (GCC) version 4.4.0 (x86_64-unknown-linux-gnu) compiled by GNU C version 4.4.0, GMP version 4.1.4, MPFR version 2.4.1. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: b0ba9d2a53d0754610d55da75a5fe542 [wait 6 minutes] g++: Internal error: Killed (program cc1plus) Please submit a full bug report. See <http://gcc.gnu.org/bugs.html> for instructions. system type: phoenix% uname -a Linux phoenix 2.6.22.9-91.fc7 #1 SMP Thu Sep 27 20:47:39 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux source file: phoenix% cat bug.C class C; C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C(C( // (40 nested unclosed constructor parentheses) expected behavior: bug.C:2: error: expected unqualified-id at end of input bug.C:2: error: expected `)' at end of input actual behavior: compiler runs for a long time, filling memory, until killed by OS. it seems to be a recursion problem. the code "class C; C(" fails immediately. every additional nesting of unclosed parentheses doubles the compile time (and the memory used) until finally with enough unclosed nestings, memory is exhausted and the OS kills the compiler process. however, it is specific to constructors. this code fails immediately: > int f(int); > f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( -- Summary: cc1plus exhausts memory with deeply nested unclosed constructor parens Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: cbm at whatexit dot org GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39992