This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/5094: partial specialisation cannot be friend??
- From: Pal Benko <benko at sztaki dot hu>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 14 Dec 2001 08:16:02 -0000
- Subject: Re: c++/5094: partial specialisation cannot be friend??
- Reply-to: Pal Benko <benko at sztaki dot hu>
The following reply was made to PR c++/5094; it has been noted by GNATS.
From: Pal Benko <benko@sztaki.hu>
To: rodrigc@gcc.gnu.org
Cc: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org,
nobody@gcc.gnu.org
Subject: Re: c++/5094: partial specialisation cannot be friend??
Date: Fri, 14 Dec 2001 09:08:51 +0100
Thank you for the quick answer.
> This is not a bug in gcc.
> This is not legal code. When I compile with
> the Digital Unix C++ compiler, I get the
> following compilation errors:
>
> cxx: Error: specfriend.cc, line 67: "c" has already been declared in =
the
> current scope
> friend class c;
> -----------------^
Is
template <>
struct c<int>
{
class inner
{
friend class c<int>;
};
template <typename T>
friend class d<c<T> >;
};
correct? gcc accepts it, but it also accepted the previous version.
> cxx: Error: specfriend.cc, line 71: class "c" may not have a template
> argument list
> friend class d<c<T> >;
> -----------------^
> cxx: Error: specfriend.cc, line 71: class "c" may not have a template
> argument list
> friend class d<c<T> >;
> -----------------^
> cxx: Error: specfriend.cc, line 71: invalid partial specialization --
> class
> "d<<error-type>>" is already fully specialized
> friend class d<c<T> >;
> ---------------^
OK, Martin Sebor gave the exact reference from the standard.
> cxx: Error: specfriend.cc, line 83: class "c" may not have a template
> argument list
> friend class c<d>;
> ---------------^
again: is
template <>
struct d<int>
{
template <int I>
class inner
{
friend class d;
};
friend class c<d<int> >;
};
correct? gcc accepts, as previously.
And there are three error messages of gcc not reproduced by the
Digital Unix C++ in lines 42, 55 and 59 of the original bugreport. A
simplified testcase:
struct b
{
template <int I>
class inner
{};
};
template <typename T>
struct c {};
template <typename T>
struct c<T*>
{
class inner
{
friend class c;
};
};
template <typename T>
struct c<c<T> >
{
template <int I>
class inner
{
friend class c;
};
template <int I>
friend class b::inner;
};
Thanks again,
Benko Pal=