This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/14811] New: Invalid granting of access to nested class.
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Apr 2004 15:59:02 -0000
- Subject: [Bug c++/14811] New: Invalid granting of access to nested class.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Given:
class outer {
enum E { foo };
struct inner {
E e; // illegal, but g++ allows it
};
};
g++ fails to reject the code. The gcc web site at
<http://gcc.gnu.org/bugs.html#nonbugs_cxx> says in part:
Defect report 45 clarifies that nested classes
are members of the class they are nested in,
and so are granted access to private members of
that class.
That statment is wrong. See the ISO/ANSI C++ standard section
11.8 example 1:
The members of a nested class have no special
access to members of an enclosing class, nor to
classes or functions that have granted
friendship to an enclosing class; the usual
access rules (clause 11) shall be obeyed.
Environment:
System: Linux g4.pauljlucas.org 2.4.19-4a #1 Wed Jun 5 01:34:59 EDT 2002 ppc unknown
Architecture: ppc
host: powerpc-unknown-linux-gnu
build: powerpc-unknown-linux-gnu
target: powerpc-unknown-linux-gnu
configured with: /tmp/gcc-3.3.3/configure --prefix=/usr/local/packages/gcc-3.3.3 --enable-threads=posix --enable-languages=c,c++ --disable-nls
How-To-Repeat:
Compile the code: g++ -c bug.c
------- Additional Comments From pauljlucas at mac dot com 2004-04-01 15:58 -------
Fix:
No work-around.
--
Summary: Invalid granting of access to nested class.
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pauljlucas at mac dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: powerpc-unknown-linux-gnu
GCC host triplet: powerpc-unknown-linux-gnu
GCC target triplet: powerpc-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14811