// PR c++/87571 template struct A { template struct B { template friend class B; protected: int protected_member_; public: template int method(const B& other) const { return other.protected_member_; } }; }; int main() { A::B a; A::B b; a.method(b); }