This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: g++ parser bug?
- To: jlnance at worldnet dot att dot net
- Subject: Re: g++ parser bug?
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Fri, 24 Mar 2000 09:05:42 +0100
- CC: gcc-bugs at gcc dot gnu dot org
- References: <20000323171922.A14265@Bessie>
> 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