First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 5094
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Kriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: benko@sztaki.hu
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
specfriend.cc specfriend.cc application/octet-stream 2003-05-21 15:16 175 bytes Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 5094 depends on: Show dependency tree
Show dependency graph
Bug 5094 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: Opened: 2001-12-12 07:26
The attached file tries several configuration of friend declaration.
Some of them fails; I think these should behave identically to those
not failing.

arta:~/c/proba$ /gml/shared/gcc-3.0.2/bin/g++ -c specfriend.cc 
specfriend.cc:42: partial specialization `c<d<T> >' declared `friend'
specfriend.cc:55: partial specialization `d<c<T> >' declared `friend'
specfriend.cc:59: expected 1 levels of template parms for `class b::inner<I>', 
   got 2
specfriend.cc:71: partial specialization `d<c<T> >' declared `friend'
zsh: exit 1     /gml/shared/gcc-3.0.2/bin/g++ -c specfriend.cc
arta:~/c/proba$

Release:
3.0.2

Environment:
SuSE 7.1, i686

------- Comment #1 From Craig Rodrigues 2001-12-12 19:58 -------
State-Changed-From-To: open->analyzed
State-Changed-Why: 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;
    -----------------^
    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> >;
    ---------------^
    cxx: Error: specfriend.cc, line 83: class "c" may not have a template
              argument list
      friend class c<d>;
    ---------------^
    cxx: Info: 5 errors detected in the compilation of "specfriend.cc".

------- Comment #2 From Martin Sebor 2001-12-12 21:23 -------
From: Martin Sebor <sebor@roguewave.com>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c++/5094: partial specialisation cannot be friend??
Date: Wed, 12 Dec 2001 21:23:58 -0700

 rodrigc@gcc.gnu.org wrote:
 > 
 > Synopsis: partial specialisation cannot be friend??
 > 
 > State-Changed-From-To: open->analyzed
 > State-Changed-By: rodrigc
 > State-Changed-When: Wed Dec 12 19:58:51 2001
 > State-Changed-Why:
 >     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:
 
 Although I also have respect for the latest version of Compaq C++,
 it should be noted that the compiler isn't "the ultimate authority"
 on the validity of C++ code. What clenches it is that 14.5.3, p9
 explicitly prohibits friend declarations of partial specializations:
 
   -9- Friend declarations shall not declare partial specializations.
       [Example:
           template<class T> class A { };
           class X {
               template<class T> friend class A<T*>; // error
           };
       —end example]
 
 Regards
 Martin


------- Comment #3 From Craig Rodrigues 2001-12-13 03:58 -------
From: rodrigc@gcc.gnu.org
To: benko@sztaki.hu, gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org,
  gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org
Cc:  
Subject: Re: c++/5094: partial specialisation cannot be friend??
Date: 13 Dec 2001 03:58:51 -0000

 Synopsis: partial specialisation cannot be friend??
 
 State-Changed-From-To: open->analyzed
 State-Changed-By: rodrigc
 State-Changed-When: Wed Dec 12 19:58:51 2001
 State-Changed-Why:
     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;
     -----------------^
     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> >;
     ---------------^
     cxx: Error: specfriend.cc, line 83: class "c" may not have a template
               argument list
       friend class c<d>;
     ---------------^
     cxx: Info: 5 errors detected in the compilation of "specfriend.cc".
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=5094&database=gcc


------- Comment #4 From benko@sztaki.hu 2001-12-14 09:08 -------
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=
 

------- Comment #5 From Kriang Lerdsuwanakij 2002-11-27 05:52 -------
Responsible-Changed-From-To: unassigned->lerdsuwa
Responsible-Changed-Why: Patch submitted.

------- Comment #6 From Kriang Lerdsuwanakij 2002-12-19 07:36 -------
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in 3.3 and main trunk.  Now only the template friend
      template <typename T> friend class d<c<T> >;
    is rejected.  The rest is accepted.

First Last Prev Next    No search results available      Search page      Enter new bug