This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/21498] New: clause 7.1.5.3/2 of the c++ is not enforced


The following code should be rejected, but is accepted by g++:


template < typename T >
class identity {
public:

  typedef T me;

};

template < typename T >
class my_friend {
private:

  friend class identity< T >::me;

  char x;

};

class The_T {
public:

  static
  char & peek_friend ( my_friend< The_T > & f ) {
    return( f.x );
  }
  
};

int main (void) {
  my_friend< The_T > x;
}


The configuration is:

gcc> g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0.0/configure --prefix=/pkg/gcc-4.0.0/usr
Thread model: posix
gcc version 4.0.0


The code is illegal because the friend declaration resolves into the
typedef "me" (7.1.5.3/2).

PS: I do not really understand why the standard is worded this way.
    It appears that templated friendship could be good.

-- 
           Summary: clause 7.1.5.3/2 of the c++ is not enforced
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jkherciueh at gmx dot net
                CC: gcc-bugs at gcc dot gnu dot org


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]