https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99160
Bug ID: 99160 Summary: A wrong accessible check when using a using-declaration that introduces the names of type and function Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: xmh970252187 at gmail dot com Target Milestone: --- ````cpp #include <iostream> struct A{ struct C{ using type = int; }; void C(){} //#1 if comment out this function definition, GCC will compile // this example }; struct B:private A{ using A::C; }; int main(){ B::C::type c; //#2 } ```` For this example, GCC will report an error, which says "'struct A::C' is inaccessible within this context". The result of this example is https://godbolt.org/z/ddfrPM. If we comment out `void C(){}`, GCC will compile the example. According to [namespace.udecl]#19. > A synonym created by a using-declaration has the usual accessibility for a > member-declaration. That means the name `C` is accessible in the nested-name-specifier at #2(the name would be found in the scope of `B` in which the using-declaration will create the synonym name for that name, the created name has the same accessibility as the member-declaration) Clang can compile this example even if we do not comment out the function definition at #1