This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21498] New: clause 7.1.5.3/2 of the c++ is not enforced
- From: "jkherciueh at gmx dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 May 2005 16:18:00 -0000
- Subject: [Bug c++/21498] New: clause 7.1.5.3/2 of the c++ is not enforced
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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