https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121676

            Bug ID: 121676
           Summary: friend elaborated-type-specifier rejects dependent
                    nested template specialization
           Product: gcc
           Version: 15.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gulackeg at gmail dot com
  Target Milestone: ---

Test code:

    // https://godbolt.org/z/KhE488z8M

    namespace test1 {
    template <class> struct A {
      template <class> struct B;
    };
    template <class T> class C {
      // - GCC: error: using typedef-name 'class A<T>::B<void>' after
      //        'class' [-Wtemplate-body]
      // - Clang/MSVC: OK
      friend class A<T>::template B<void>;
      friend typename A<T>::template B<void>; // OK
    };
    template class C<void>;
    } // namespace test1

    namespace test2 {
    struct A {
      template <class> struct B;
    };
    template <class T> class C {
      // - GCC: error: expected identifier before ';' token
      //        [-Wtemplate-body]
      // - Clang/MSVC: OK
      friend class T::template B<void>;
      friend typename T::template B<void>; // OK
    };
    template class C<A>;
    } // namespace test2

I'm not sure why GCC rejects the test cases above, and the errors it emits are
also somewhat confusing.

Reply via email to