https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66475
Bug ID: 66475 Summary: Access checking in templates circumvented with 'using' (C++11) Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zerolo at gmail dot com Target Milestone: --- Created attachment 35731 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35731&action=edit repo that compiles with g++-4.9.2 -std=c++11 This is a variant of the various access checking problems when using templates, but I don't think it's a duplicate of any of the existing ones in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59002 , as this one is only triggered with the `using` directive in C++11 mode, but not when employing the supposedly identical typedef. Code that accesses a type that should be private compiles, even though it shouldn't be able to. When either a) the using directive "using Base = Foo<T>" is replaced by the equivalent typedef, or b) later no other type from Base is publicized, then access is correctly prohibited and the example fails to compile. // g++-4.9.2 -std=c++11 t.cpp template<class T> struct Foo { using type = T; }; template<class T> class Bar : public Foo<T> { using Base = Foo<T>; // the combination of this and the public export of a type from Base below, causes this example to compile even though it shouldn't // typedef Foo<T> Base; // when using typedef instead of using, it correctly fails to compile public: // without this public export, Base is correctly recognized as private, maybe it erroneously make Base itself public? // whether written as 'typedef' or 'using' doesn't matter using type = typename Base::type; }; Bar<int>::Base x; // shouldn't compile, Base is private int main() { return 0; }