c++/9549: [3.4 regression] [New parser] ICE in regenerate_decl_from_template
Martin Sebor
sebor@roguewave.com
Mon Feb 3 19:56:00 GMT 2003
Wolfgang Bangerth wrote:
...
>
>
> I understand the reasoning for the necessity of the "template" keyword
> here.
>
> This is 14.2.4 text and example from the 1997 draft I use:
> When the name of a member template specialization appears after . or
> -> in a postfix-expression, or after :: in a qualified-id that explic-
> itly depends on a template-argument (_temp.dep_), the member template
> name must be prefixed by the keyword template. Otherwise the name is
> assumed to name a non-template. [Example:
> class X {
> public:
> template<size_t> X* alloc();
> };
> void f(X* p)
> {
> X* p1 = p->alloc<200>();
> // ill-formed: < means less than
>
> X* p2 = p->template alloc<200>();
> // fine: < starts explicit qualification
> }
> --end example]
>
> Clearly, the lhs is not template-dependent. Has this been changed
> afterwards? That might explain our mismatch!?
I believe so. Here's what's in the final text:
-4- When the name of a member template specialization
appears after . or > in a postfix-expression, or after
nested-name-specifier in a qualified-id, and the
postfix-expression or qualified-id explicitly depends on
a template-parameter (14.6.2), the member template name
must be prefixed by the keyword template.
Otherwise the name is assumed to name a non-template.
[Example:
class X {
public:
template<size_t> X* alloc();
template<size_t> static X* adjust();
};
template<class T> void f(T* p)
{
T* p1 = p->alloc<200>();
// ill-formed: < means less than
T* p2 = p->template alloc<200>();
// OK: < starts template argument list
T::adjust<100>();
// ill-formed: < means less than
T::template adjust<100>();
// OK: < starts explicit qualification
}
--end example]
Martin
More information about the Gcc-bugs
mailing list