From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17561 invoked by alias); 3 Feb 2003 19:46:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 17532 invoked by uid 71); 3 Feb 2003 19:46:00 -0000 Date: Mon, 03 Feb 2003 19:46:00 -0000 Message-ID: <20030203194600.17531.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Martin Sebor Subject: Re: c++/9549: [3.4 regression] [New parser] ICE in regenerate_decl_from_template Reply-To: Martin Sebor X-SW-Source: 2003-02/txt/msg00136.txt.bz2 List-Id: The following reply was made to PR c++/9549; it has been noted by GNATS. From: Martin Sebor To: Wolfgang Bangerth Cc: bangerth@dealii.org, gcc-gnats@gcc.gnu.org Subject: Re: c++/9549: [3.4 regression] [New parser] ICE in regenerate_decl_from_template Date: Mon, 03 Feb 2003 12:37:26 -0700 Wolfgang Bangerth wrote: >>> This is not a bug. You need to write >>> m.template do_it(); >> >>This is incorrect, as is your previous analysis in PR #9510: >>http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9510 >> >>This syntax is required only if the right hand side of the ^^^^^^^^^^^^^^^ I meant left hand side here, not right hand side. Sorry. >>dot operator depends on a template parameter, otherwise it >>is optional. Please read 14.2, p4 for more. > > > Ehm, but in m.do_it, the rhs of the dot operator _is_ template > dependent, no? 14.2.4 has almost the same example and says that you need > the template keyword -- what am I missing here? If the left hand side does not depend on a template parameter, there is no reason to use the template prefix since the name to the right of the dot is known to either be a template or not at the point of parsing the "surrounding" template and there is no possibility of an ambiguity with the less than operator. Otherwise it may or may not be a template, and the first "<" may or may not be a less than operator, depending on any specializations of the template to the left of the dot operator. For instance, in the example below, the declaration enum { e = A::B::e + 1 }; is parsed as enum { e = (A::B) < (J - 1) > (::e + 1) }; ^^^^^^^ ^ ^ | | +- operator>() | +- operator<() +-template argument list without the template keword because at the point of definition of the primary template A it's not known whether B is or is not a template. With the template keyword, A::template B would be parsed as the type name of the template B. The same logic applies to the dot operator as well as to operator-> enum { e }; template struct A { template struct B { enum { e = A::B::e + 1 }; }; }; template<> struct A<0> { enum { B }; }; int main () { return A<1>::B<1>::e; } Martin