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]

Re: g++ parser bug?


>     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

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