[Bug c++/13967] [3.3?/3.4/3.5 regression] template template argument identifier lookup fails scoping rules
gdr at integrable-solutions dot net
gcc-bugzilla@gcc.gnu.org
Mon Feb 2 17:40:00 GMT 2004
------- Additional Comments From gdr at integrable-solutions dot net 2004-02-02 17:40 -------
Subject: Re: [3.3?/3.4/3.5 regression] template template argument identifier lookup fails scoping rules
"gianni at mariani dot ws" <gcc-bugzilla@gcc.gnu.org> writes:
| Gabriel Dos Reis writes:
| |
| || So I'm confused as to what you mean "should be found". Can you cite
| || the standard ?
| |
| | What I meant is this:
| |
| | struct X {
| | int C;
| |
| | template<class> void func();
| | };
| |
| |
| | template<class C>
| | void X::func()
| | {
| | C c; // ERROR: C is not a type.
| | }
| |
| | In the definition of X::func(), lookup for C will find X::C instead of
| | the template parameter.
|
| Yes - but is this the behaviour as specified in the standard ?
I just checked with the Core group and John Spicer recalled that the
committee madethe general decision that a class-member hides a
template-parameter. See the implementation of that decision in
14.6.1/5 and 14.6.1/7.
| At first glance, it seems like the gcc behaviour is probably wrong.
But, GCC behaviour is Right :-)
The fundamental issue is that template-parameters can be renamed and
you don't want to depend on that. Consider
template<class T>
struct X {
struct B { };
void f();
};
template<class B>
void X<B>::f()
{
B* p = 0; // 'B' is X<>::B, not the template parameter
}
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13967
More information about the Gcc-bugs
mailing list