This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GCC 3.0 20010526: compiler goes into infinite loop during parsing C++


The following C++ code fragment hangs gcc-3.0-20010527 during
the C++ parsing stage.  Running under gdb, the code appears to get into
an endless loop inside cc1plus:yyparse_1 (gcc/cp/parse.[yc] ?) never
managing to recover from the final error.  (The .ii file is identical
to the .cc file [barring #line], .s file is empty.)

The errors reported by g++ seem to be confused after the first line.
(For "confused" read "misleading" or "wrong" :-)

The hang doesn't occur with the gcc 2.96 release shipped with Mandrake 8.0
- the point at which the gcc 3.0 code hangs generates a "confused by earlier
errors, bailing out" message.  (Deleting pretty much any line of code clears
the problem - only the A::struct L defn is superfluous.)


{The mistake in the code sample (this is a vastly simplified test case -
the original cpp output was ~30000 lines thanks to using STL) is forgetting
to declare X, but since it requires a number of other contributing
factors it probably won't occur that often in normal use.
(And probably doesn't impact "correct" code.)  Fortunately, the first
error message gives the information necessary to fix it.}


Phil, pgr at derived-software dot demon dot co dot uk


--loopy3.cc--
struct A
{
  A (X *) {}
  struct L { int a; };
};

struct B
{
  const A::L& al () const { return l; }
  A::L l;
};

struct C
{
  C () {}
};
--END--

uname -a: Linux derisoft 2.4.3-20mdk #1 Sun Apr 15 23:03:10 CEST 2001 i686
(Mandrake 8.0)

% g++ -v loopy3.cc -c
Reading specs from /home/pgr/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0/specs
Configured with: ../gcc-3.0-20010527/configure --prefix=/home/pgr/gcc3 \
  --enable-threads
Thread model: posix
gcc version 3.0 20010526 (prerelease)
 /home/pgr/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0/cc1plus -v -D__GNUC__=3 \
  -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux \
  -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix \
  -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ \
  -D__tune_i686__ -D__tune_pentiumpro__ loopy3.cc -D__GNUG__=3 -D_GNU_SOURCE \
  -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase \
  loopy3.cc -version -o /tmp/ccLs7ouq.s
GNU CPP version 3.0 20010526 (prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.0 20010526 (prerelease) (i686-pc-linux-gnu)
	compiled by GNU C version 3.0 20010526 (prerelease).
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/home/pgr/gcc3/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/pgr/gcc3/include/g++-v3
 /home/pgr/gcc3/include/g++-v3/i686-pc-linux-gnu
 /home/pgr/gcc3/include/g++-v3/backward
 /home/pgr/gcc3/lib/gcc-lib/i686-pc-linux-gnu/3.0/include
 /usr/include
End of search list.
loopy3.cc:3: parse error before `*' token
loopy3.cc:3: missing ';' before right brace
loopy3.cc:4: semicolon missing after declaration of `A'
loopy3.cc:4: multiple types in one declaration
loopy3.cc:5: parse error before `}' token
loopy3.cc:9: parse error before `&' token
loopy3.cc:10: ISO C++ forbids defining types within return type
loopy3.cc:10: syntax error before `;' token
loopy3.cc: In constructor `A::C::C()':
loopy3.cc:15: parse error before `;' token

[loops forever inside yyparse_1]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]