This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/9549: [3.4 regression] [New parser] ICE in regenerate_decl_from_template
- From: Martin Sebor <sebor at roguewave dot com>
- To: Wolfgang Bangerth <bangerth at ticam dot utexas dot edu>
- Cc: gcc-gnats at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org
- Date: Mon, 03 Feb 2003 12:55:36 -0700
- Subject: Re: c++/9549: [3.4 regression] [New parser] ICE in regenerate_decl_from_template
- Organization: Rogue Wave Software, Inc.
- References: <Pine.LNX.4.44.0302031342110.8447-100000@gandalf.ticam.utexas.edu>
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