http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58428

            Bug ID: 58428
           Summary: Compile error when declare nested class as a friend of
                    another template class.
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ytj000 at gmail dot com

Created attachment 30824
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30824&action=edit
broken code

OS: Archlinux x64 
Kernel: 3.10.10-1
GCC: Tried 4.8.1 and git version a5ceabb48759ee5937184d49e1773085e63f1130
command line: g++ bug.cpp

clang++ (3.3) could compile the following code successfully. However, gcc
failed to compile it and gave such error:

  bug.cpp: In instantiation of ‘class C<int>’:
  bug.cpp:8:10:   required from here
  bug.cpp:4:28: error: no type named ‘B’ in ‘class A<int, U>’
   template <class T> class C {

------------------------------------------
template <class T, class U> class A {
  class B {};
};
template <class T> class C {
  template <class U> friend class A<T, U>::B;
};
int main() {
  C<int>();
}
------------------------------------------

Reply via email to