public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/8280: friend declaration introduces class name into namespace scope
@ 2002-10-18 16:56 dbaron
  0 siblings, 0 replies; only message in thread
From: dbaron @ 2002-10-18 16:56 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8280
>Category:       c++
>Synopsis:       friend declaration introduces class name into namespace scope
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 18 16:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     dbaron@fas.harvard.edu
>Release:        3.2
>Organization:
>Environment:
Configured with: ../gcc-3.2/configure --prefix=/usr/local/gcc-3.2 --enable-languages=c++ --enable-__cxa_atexit
Thread model: posix
gcc version 3.2

(on Linux 2.4.18-17.8.0smp i686, i.e., RedHat 8.0)

Also present on gcc trunk:
  gcc version 3.3 20021007 (experimental)
>Description:
According to section 7.3.1.2, clause 3, of the C++
standard:
  If a |friend| declaration in a non-local class first
  declares a class or function the friend class or
  function is a member of the innermost enclosing
  namespace.  The name of the friend is not found
  by simple name lookup until a matching declaration
  is provided in that namespace scope (either before
  or after then class declaration granting friendship).

In other words (I think), |friend class B| is allowed
even if B hasn't been declared yet, but it doesn't
declare B.

I have been told that this was not true in older
drafts of the standard.
>How-To-Repeat:
The following source code is sufficient to reproduce
the problem:
-----
class A { friend class B; };

// The name |B| should not be found yet, so this
// should not compile.
B* null_b() { return 0; }

int main() { return 0; }
-----
Compile with:
g++ -o friend -ansi -pedantic test.cpp
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-18 23:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-18 16:56 c++/8280: friend declaration introduces class name into namespace scope dbaron

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).