strange thing with template evaluation

Edwards, Phil pedwards@ball.com
Wed May 12 08:08:00 GMT 1999


+ Nope.  In this case, g++ is right.  The general rule is: if
+ some sequence of tokens can be parsed as a declaration (as
+ opposed to a statement), it must be.  If some sequence of tokens
+ can be parsed as a type name (as opposed to an expression), it
+ must be.  Since `C2()', is a type name, it is parsed as an
+ unnamed parameter, and c1 is the declaration of a function.

As an objective observer, all that made sense to me.

What confuses me is that changing

	C1<C2>  c1(C2());

to

	auto C1<C2>  c1(C2());

doesn't help ("storage class `auto' invalid for function `c1'").  I would
have thought that 'auto' would dominate the decision-making here, since
auto's raison d'etre seems to be resolving variable declaration ambiguity.


+ A simple trick to resolve the ambiguity in favor of an 
+ expression is to add extra parentheses around the whole 
+ expression: `c1((C2()))'

Erm.  This gave me a parse error, with and without 'auto' present.  Now I'm
extra-confused...


Phil



More information about the Gcc-bugs mailing list