g++ parser bug?
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Fri Mar 24 00:10:00 GMT 2000
> I think I may have found a bug in the g++ parser.
Thanks for your bug report. Please have a look at
http://www.gnu.org/software/gcc/bugs.html#parsing
> c foo1(a()); // Compiles & runs, but does not do anything
This declares an extern function foo1, expecting a function returning
a expecting no arguments, returning c. Since it is a declaration, it
does nothign.
> c foo2((class a) a()); // Compiles, and runs properly
Since this can't be interpreted as a function declaration, it is an
object declaration.
> c foo3(a(),1); // Does not compile (must be barfing on the "1")
This is an instance of the bug. The compiler starts parsing and
assumes a function declaration. When it then sees the expression, it
cannot go back an reconsider.
> c foo4((class a) a(),1); // Compiles and runs properly
Please note that a different solution is
c foo4((0,a()),1);
Regards,
Martin
More information about the Gcc-bugs
mailing list