public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21901] New: Nested class has access to Nestee's private member functions
@ 2005-06-03 14:59 mhcox at bluezoosoftware dot com
2005-06-03 15:29 ` [Bug c++/21901] " pinskia at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: mhcox at bluezoosoftware dot com @ 2005-06-03 14:59 UTC (permalink / raw)
To: gcc-bugs
When compiling the following code I get no error (should get access violation
on bar's constructor's access of foo's private foobar() ):
# 1 "bug050603.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "bug050603.cc"
class foo
{
public:
foo() { }
class bar
{
public:
bar() { foo::foobar(); }
};
private:
static int foobar();
};
Note that this problems also occurs in 3.3.1 on a Solaris 2.6 Sparc box. I
don't have access to any newer compilers to see if it's fixed in latter
releases.
I found one bug (12226) that sounds related.
Output of g++ -v:
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.3/specs
Configured with: /gcc/gcc-3.3.3-3/configure --verbose --prefix=/usr --exec-
prefi
x=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --
mandir=/usr/s
hare/man --infodir=/usr/share/info --enable-
languages=c,ada,c++,d,f77,java,objc,
pascal --enable-nls --without-included-gettext --enable-libgcj --with-system-
zli
b --enable-interpreter --enable-threads=posix --enable-java-gc=boehm --enable-
sj
lj-exceptions --disable-version-specific-runtime-libs --disable-win32-registry
Thread model: posix
gcc version 3.3.3 (cygwin special)
--
Summary: Nested class has access to Nestee's private member
functions
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: mhcox at bluezoosoftware dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21901
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21901] Nested class has access to Nestee's private member functions
2005-06-03 14:59 [Bug c++/21901] New: Nested class has access to Nestee's private member functions mhcox at bluezoosoftware dot com
@ 2005-06-03 15:29 ` pinskia at gcc dot gnu dot org
2005-06-03 17:46 ` bangerth at dealii dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-03 15:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-03 15:29 -------
Why do you think this is invalid code and should be rejected?
This is accepted by Comeau's C++ compiler too.
I don't have the standard right in the front of me right now but I think this is valid code.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21901
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21901] Nested class has access to Nestee's private member functions
2005-06-03 14:59 [Bug c++/21901] New: Nested class has access to Nestee's private member functions mhcox at bluezoosoftware dot com
2005-06-03 15:29 ` [Bug c++/21901] " pinskia at gcc dot gnu dot org
@ 2005-06-03 17:46 ` bangerth at dealii dot org
2005-06-04 17:17 ` mhcox at bluezoosoftware dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2005-06-03 17:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-06-03 17:46 -------
Nested class, like all other members of a class, have access to private
and protected members. That's what the standard says.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21901
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21901] Nested class has access to Nestee's private member functions
2005-06-03 14:59 [Bug c++/21901] New: Nested class has access to Nestee's private member functions mhcox at bluezoosoftware dot com
2005-06-03 15:29 ` [Bug c++/21901] " pinskia at gcc dot gnu dot org
2005-06-03 17:46 ` bangerth at dealii dot org
@ 2005-06-04 17:17 ` mhcox at bluezoosoftware dot com
2005-06-04 17:20 ` mhcox at bluezoosoftware dot com
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mhcox at bluezoosoftware dot com @ 2005-06-04 17:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mhcox at bluezoosoftware dot com 2005-06-04 17:17 -------
Subject: RE: Nested class has access to Nestee's private member functions
>From my copy of the C++ standard (ISO/IEC 14882:1998(E)) [class.access.net]
11.8.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 ruls (clause 11) shal be
Obeyed. The members of an enclosing class have no special access to
members of a nested class; the usual
Access rules (clause 11) shall be obeyed.
I read suggestions that this should be changed in the next standard, but I
don't think it's changed yet. Therefore, the resolution shouldn't be
INVALID. It either needs to fixed or documented as a non-standard extension
(in anticipation of the next standard's changes).
Mike
-----Original Message-----
From: bangerth at dealii dot org [mailto:gcc-bugzilla@gcc.gnu.org]
Sent: Friday, June 03, 2005 11:46 AM
To: mhcox@bluezoosoftware.com
Subject: [Bug c++/21901] Nested class has access to Nestee's private member
functions
------- Additional Comments From bangerth at dealii dot org 2005-06-03
17:46 ------- Nested class, like all other members of a class, have access
to private and protected members. That's what the standard says.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21901
------- You are receiving this mail because: ------- You reported the bug,
or are watching the reporter.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21901
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21901] Nested class has access to Nestee's private member functions
2005-06-03 14:59 [Bug c++/21901] New: Nested class has access to Nestee's private member functions mhcox at bluezoosoftware dot com
` (2 preceding siblings ...)
2005-06-04 17:17 ` mhcox at bluezoosoftware dot com
@ 2005-06-04 17:20 ` mhcox at bluezoosoftware dot com
2005-06-04 17:37 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: mhcox at bluezoosoftware dot com @ 2005-06-04 17:20 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mhcox at bluezoosoftware dot com 2005-06-04 17:20 -------
>From my copy of the C++ standard (ISO/IEC 14882:1998(E)) [class.access.net]
11.8.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. The members of an enclosing class have no special access to
members of a nested class; the usual
Access rules (clause 11) shall be obeyed.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21901
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21901] Nested class has access to Nestee's private member functions
2005-06-03 14:59 [Bug c++/21901] New: Nested class has access to Nestee's private member functions mhcox at bluezoosoftware dot com
` (3 preceding siblings ...)
2005-06-04 17:20 ` mhcox at bluezoosoftware dot com
@ 2005-06-04 17:37 ` pinskia at gcc dot gnu dot org
2005-06-04 17:38 ` pinskia at gcc dot gnu dot org
2005-06-04 18:48 ` bangerth at ices dot utexas dot edu
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-04 17:37 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-04 17:37 -------
Reopening for a second to ...
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21901
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21901] Nested class has access to Nestee's private member functions
2005-06-03 14:59 [Bug c++/21901] New: Nested class has access to Nestee's private member functions mhcox at bluezoosoftware dot com
` (4 preceding siblings ...)
2005-06-04 17:37 ` pinskia at gcc dot gnu dot org
@ 2005-06-04 17:38 ` pinskia at gcc dot gnu dot org
2005-06-04 18:48 ` bangerth at ices dot utexas dot edu
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-04 17:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-04 17:38 -------
Mark as a dup of bug 359.
This was DR 45.
*** This bug has been marked as a duplicate of 359 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21901
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/21901] Nested class has access to Nestee's private member functions
2005-06-03 14:59 [Bug c++/21901] New: Nested class has access to Nestee's private member functions mhcox at bluezoosoftware dot com
` (5 preceding siblings ...)
2005-06-04 17:38 ` pinskia at gcc dot gnu dot org
@ 2005-06-04 18:48 ` bangerth at ices dot utexas dot edu
6 siblings, 0 replies; 8+ messages in thread
From: bangerth at ices dot utexas dot edu @ 2005-06-04 18:48 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at ices dot utexas dot edu 2005-06-04 18:48 -------
Subject: RE: Nested class has access to Nestee's private
member functions
> I read suggestions that this should be changed in the next standard, but I
> don't think it's changed yet. Therefore, the resolution shouldn't be
> INVALID. It either needs to fixed or documented as a non-standard extension
> (in anticipation of the next standard's changes).
It is part of the Technical Corrigendum TC1 of the standard, however, and
therefore (retroactively) considered part of C++98.
W.
-------------------------------------------------------------------------
Wolfgang Bangerth email: bangerth@ices.utexas.edu
www: http://www.ices.utexas.edu/~bangerth/
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21901
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-06-04 18:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-03 14:59 [Bug c++/21901] New: Nested class has access to Nestee's private member functions mhcox at bluezoosoftware dot com
2005-06-03 15:29 ` [Bug c++/21901] " pinskia at gcc dot gnu dot org
2005-06-03 17:46 ` bangerth at dealii dot org
2005-06-04 17:17 ` mhcox at bluezoosoftware dot com
2005-06-04 17:20 ` mhcox at bluezoosoftware dot com
2005-06-04 17:37 ` pinskia at gcc dot gnu dot org
2005-06-04 17:38 ` pinskia at gcc dot gnu dot org
2005-06-04 18:48 ` bangerth at ices dot utexas dot edu
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).