public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jkherciueh at gmx dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/21498] New: clause 7.1.5.3/2 of the c++ is not enforced
Date: Tue, 10 May 2005 16:18:00 -0000	[thread overview]
Message-ID: <20050510161755.21498.jkherciueh@gmx.net> (raw)

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


             reply	other threads:[~2005-05-10 16:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-10 16:18 jkherciueh at gmx dot net [this message]
2005-05-10 16:31 ` [Bug c++/21498] " pinskia at gcc dot gnu dot org
2005-08-14 16:48 ` fn_x at hotmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050510161755.21498.jkherciueh@gmx.net \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).