This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/7218: incorrect 'implicit typename' warnings
- From: Kriang Lerdsuwanakij <lerdsuwa at users dot sourceforge dot net>
- To: Ryohei Noda <ndry at mdcplus dot com>
- Cc: gcc-gnats at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, lerdsuwa at gcc dot gnu dot org, nobody at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org
- Date: Sat, 13 Jul 2002 17:25:07 +0700
- Subject: Re: c++/7218: incorrect 'implicit typename' warnings
- References: <200207121849.g6CInGw14966@mail19.bigmailbox.com>
- Reply-to: lerdsuwa at users dot sourceforge dot net
Ryohei Noda wrote:
>
> lerdsuwa:
>
> Thank you for your reply.
> But I have not convinced.
>
> The C++ ISO Standard(14882:1998) reads:
> 14.6 8(p259)
> > The lookup of names dependent on the template parameter is
> > postponed until the actual template argument is known(14.6.2).
>
> Compiler should not complain about failing to look up AA
> when parsing the code.
>
> 14.6.2 3
> > In the definition of a class template or in the definition of
> > a member of such a template that appears outside of the template
> > definition, if a base class of this template depends on a
> > template-parameter,
> > the base class scope is not examined during name lookup
> > until the class template is instantiated.
>
> The base class scope is examined,
> after the actual template argument is known and the class template
> (and implicitly the base class template)are instantiated.
>
> Have I something misineterpreted?
You're incorrect about whether the name 'AA' is template parameter
dependent. Take a look at your code (which is the same as the one
in 14.6.2 3 except various name interchange):
template<class T>
struct B : A<T> { AA a;};
'AA' specified this way is NOT a template parameter dependent name
according to 14.6.2.1 1. This 'AA' must be looked up in the scope
that contain the template class 'B'. But the name is not found.
So the code parsing fails and you see the warning message.
To force the compiler to behave like 14.6 8 and 14.6.2 3 you
mentioned. You must force GCC to view 'AA' as a dependent name.
Because base class 'A<T>' is template parameter dependent. You can
form a type dependent via 14.6.2.1 1 case 2 (a qualified-id
with a nested-name-specifier which contains a class-name that
names a dependent type), i.e. 'typename A<T>::B'.
'typename A<T>::B' is a qualified-id. Its nested-name-specifier is
'A<T>'.
--Kriang
>
> > Date: 11 Jul 2002 14:50:01 -0000
> > lerdsuwa@gcc.gnu.org Re: c++/7218: incorrect 'implicit typename' warnings
> >Synopsis: incorrect 'implicit typename' warnings
> >
> >State-Changed-From-To: open->closed
> >State-Changed-By: lerdsuwa
> >State-Changed-When: Thu Jul 11 07:50:00 2002
> >State-Changed-Why:
> > Not a bug. AA is inside template-parameter dependent
> > base class. When parsing class B, names inside A<T>
> > are not looked up. You have to write
> > template<class T>
> > struct B : A<T> { typename A<T>::AA a;};
> >
> >http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7218
>
> ------------------------------------------------------------
> Your Free, Private, Fast, E-mail and WebSite: http://MdCplus.com/email
> Join the MdCplus affiliates program and Make MONEY: http://MdCplus.com/$/?bmb
>
> ---------------------------------------------------------------------
> Express yourself with a super cool email address from BigMailBox.com.
> Hundreds of choices. It's free!
> http://www.bigmailbox.com
> ---------------------------------------------------------------------