In the appended snippet of code, the Foo2 class is only forward-declared in the
context of a "friend" statement ("friend class Foo2").  With gcc 3.2.3 this
sufficed to forward-declare it.  With gcc 4.0.2 you must have a forward
declaration without a "friend" qualifier or gcc won't recognize the class type
name when it encounters it later.  Compiling this snippet yields "ISO C++
forbids declaration of ‘Foo2’ with no type".

class Bar {
  class Foo1;
  friend class Foo1;
  friend class Foo2;
  Foo1* foo1;
  Foo2* foo2;
};


-- 
           Summary: "friend class" forward declaration doesn't actually
                    declare class
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: metcalf at lcs dot mit dot edu
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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

Reply via email to