This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: g++ 3.4.0 : C++ templates' error messages
- From: llewelly at xmission dot com
- To: Shelly Adhikari <shelly at interrasystems dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 11 May 2004 21:28:11 -0600
- Subject: Re: g++ 3.4.0 : C++ templates' error messages
- References: <40A17AC2.8010704@InterraSystems.com>
Shelly Adhikari <shelly@interrasystems.com> writes:
> Hello Guys,
>
> The following code compiled fine with gcc 3.3.3, but is giving me
> errors in gcc 3.4.0. Uncommenting any of the two commented lines,
> removes the error. Is the uncommented code incorrect [an explanation
> or citing the relevant section of the C++ standard would be nice], or
> is it a bug in 3.4.0? If it is not a bug, the error message should be
> made clearer, if possible.
>
> template <class T> class A;
> template <class T> class B;
> template <class T> class C;
> template <class T> class D;
>
> template <class T> class A {
> protected:
> int a;
> A() { }
> virtual ~A() { }
> virtual bool IsB() const = 0;
> friend class D<T>;
> friend class C<T>;
> };
>
> template <class T> class B : public A<T> {
> protected:
> int b;
> B() { }
> virtual ~B() { }
> bool IsB() const { return true; }
> bool PB() { return true; }
> friend class C<T>;
> friend class D<T>;
> friend bool C<T>::CC(A<T>* a) const;
The problem is this friend decl. It refers to a protected
member. "A name nominated by a friend declaration shall be
accessible in the scope of the class containing the friend
declaration. " (from 11.4/7)
See http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#209 for
some discussion.
> };
[snip]