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

--- Comment #2 from fabien at gcc dot gnu.org ---
(In reply to Andrew Stubbs from comment #0)
> The problem should be that B::foo hides A::foo from class C. Clause 7.3.3/14
> of the C++ standard says the using declaration should not work, in this case
> - class A is not a direct base class of class C. However, GCC 4.1.1 accepts
> it with no diagnostic.

7.3.3/14 says "...The base class members mentioned by a using-declaration shall
be visible in the scope of at least one of the direct base classes of the class
where the using-declaration is specified..."

In the example above, A (from using A::foo) is visible from its direct base
class B. Consequently, it is valid. Adding 'using A::foo' within B does not
change anything to that.

without 'using A::foo':
'int B::foo(long)' hides int A::foo(int) in B
and 'using A::foo' brings 'int A::foo(int)' into C and hides 'int
B::foo(long)'.

with 'using A::foo':
two overloads of 'foo' are present in B: 'int B::foo(long)' and 'int
A::foo(int)' (brought into B scope by the using-declaration).
and 'using A::foo' brings 'int A::foo(int)' into C and hides 'int B::foo(long)'
(and 'using A::foo)

Reply via email to