Shelly Adhikari wrote:
Should I file a bug against gcc 3.4.0, the following compiles fine
with gcc 3.3.3 but gives errors with gcc 3.4.0.
-----------------------------------------------------------------------------
----------------------------------------------
template <class A> class C;
template <class A> class B {
public:
B() { }
~B() { }
protected:
int abc;
void g() {}
friend void C<A>::f(B<A>* p);
};
template <class A> class C : public B<A> {
public:
void f(B<A>* p) {
p->g();
int m = p->abc;
}
};
int main() {
B<int>* y = new B<int>();
C<int> x;
x.f(y);
}
-----------------------------------------------------------------------------
----------------------------------------------
The code is ill-formed: the instantiation of B<int> triggers an instantiation
of C<int> in the friend declaration, which in turns triggers another
instantiation of B<int> (as base member). The recursion is detected and
compilation is stopped (in fact, while instatiating C<int>, B<int> is still
incomplete).
This probably happens due to some patches to handle the friend declarations
better.
Giovanni Bajo