4

Consider the following (artificial) example:

class A {
 public:
  template <typename T>
  class C {};
};

class B : private A {
 public:
  using A::C;
};

int main() {
  B::C<int> c;
}

It compiles successfully with both GCC and Clang, but Visual C++ 2010 gives the following error:

test.cpp(13): error C2247: 'A::C' not accessible because 'B' uses 'private' to inherit from 'A'

Is this a bug in Visual C++ or this code is indeed invalid?

If C is not a template, the code compiles on all compilers.

vitaut
  • 49,672
  • 25
  • 199
  • 336

1 Answers1

5

[namespace.udecl]/p18:

The alias created by the using-declaration has the usual accessibility for a member-declaration.

Not much to say here. The name B::C is publicly accessible, and the code is well-formed. Just another MSVC bug.

T.C.
  • 133,968
  • 17
  • 288
  • 421