This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/34184] Scope broken for inherited members inside template class?



------- Comment #2 from scovich at gmail dot com  2007-11-23 02:06 -------
Subject: Re:  Scope broken for inherited members inside template class?

On 22 Nov 2007 21:03:11 -0000, pinskia at gcc dot gnu dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
> The issue comes down to if bar is dependent here and if so is baz's base.
>
> The namelookup rules for being dependent are weird and hard to understand
> really and actually changes namelookup in some cases so we have to go what the
> standard says.
>

Somehow I'm not surprised the standard is confusing on this point...
my (unqualified) opinion is that bar and baz don't depend on foo's
template parameter. While foo<int>::bar is certainly not the same
class as foo<char>::bar, bar's relationship to baz is always the same
for any instantiation -- part of the template itself.

Imagine that, instead of declaring bar and baz inside "template<class
T> foo" we put them inside an anonymous namespace. What aspect of name
lookup has changed so that baz can suddenly find 'bar::i' without
hand-holding?

I just found an interesting phenomenon -- if baz declares it is "using
bar::i" life is suddenly good. Apparently the compiler is able to
determine that bar is, in fact, a parent class of baz, and that the
using clause is valid. However, it doesn't notice a problem with
"using bar::j" until you actually instantiate a foo<*>::baz. Given
that the compiler does know bar is a base class of baz, shouldn't any
name lookup within baz check for matching members of bar?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34184


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]