public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mmitchel at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/30917] [4.1/4.2/4.3 Regression] ICE with friend in local class (to a function)
Date: Sun, 08 Jul 2007 22:41:00 -0000	[thread overview]
Message-ID: <20070708224056.18219.qmail@sourceware.org> (raw)
In-Reply-To: <bug-30917-6528@http.gcc.gnu.org/bugzilla/>



------- Comment #5 from mmitchel at gcc dot gnu dot org  2007-07-08 22:40 -------
Simon --

It took me a while to decide that this patch was OK -- but it is. :-)  I will
suggest a few changes to make it more obviously correct.

First, minor coding style nit: drop the else after the return that you've
introduced.

Second, we need some chapter-and-verse in here.  Please avoid references like
"11.4.8" as the numbers tend to move around as the standard changes.  (For
example, I don't think 11.4.8 is the right reference in either the published
standard or the current WP.) 

For the comment on the gcc_asert, I would say:

/* A non namespace-scope binding can only be hidden if we
   are in a local class, due to friend declarations.  In particular,
   consider:

     void f() { 
      struct A { 
        friend struct B; 
        void g() { B* b; } // error: B is hidden
      } 
      struct B {};
     }

   The standard says that "B" is a local class in "f" (but not nested within
   "A") -- but that name lookup for "B" does not find this declaration until
   it is declared directly with "f".

   In particular:

   [class.friend]

   If a friend declaration appears in a local class and the name specified
   is an unqualified name, a prior declaration is looked up without considering 
   scopes that are outside the innermost enclosing non-class scope....
   For a friend class declaration, if there is no prior declaration, the class
   that is specified belongs to the innermost enclosing non-class scope, but 
   if it is subsequently referenced, its name is not found by name lookup until
   a matching declaration is provided in the innermost enclosing nonclass 
   scope.
*/

OK with that change.

Thanks,

-- Mark


-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simartin at users dot
                   |                            |sourceforge dot net


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


  parent reply	other threads:[~2007-07-08 22:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-21 18:24 [Bug c++/30917] New: " pinskia at gcc dot gnu dot org
2007-02-21 18:24 ` [Bug c++/30917] " pinskia at gcc dot gnu dot org
2007-02-22  6:53 ` [Bug c++/30917] [4.3 Regression] " pinskia at gcc dot gnu dot org
2007-02-22  9:36 ` [Bug c++/30917] [4.1/4.2/4.3 " rguenth at gcc dot gnu dot org
2007-03-05  4:01 ` mmitchel at gcc dot gnu dot org
2007-03-08  6:55 ` patchapp at dberlin dot org
2007-07-08 22:41 ` mmitchel at gcc dot gnu dot org [this message]
2007-07-28 10:48 ` simartin at gcc dot gnu dot org
2007-07-28 20:13 ` simartin at gcc dot gnu dot org
2007-07-28 20:14 ` [Bug c++/30917] [4.1 " simartin at gcc dot gnu dot org
2007-08-30 16:33 ` jason at gcc dot gnu dot org

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=20070708224056.18219.qmail@sourceware.org \
    --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).