public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Boris.Maric@consol.de
To: gcc-gnats@gcc.gnu.org
Subject: c++/8813: members of a nested class should not have special access to members of an enclosing class
Date: Wed, 04 Dec 2002 10:36:00 -0000	[thread overview]
Message-ID: <20021204183344.23116.qmail@sources.redhat.com> (raw)


>Number:         8813
>Category:       c++
>Synopsis:       members of a nested class should not have special access to members of an enclosing class
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 04 10:36:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Boris.Maric@consol.de
>Release:        gcc Version 2.95.2 3.2 and probably others
>Organization:
>Environment:
Solaris 8 and Solaris 2.6 and probably others
>Description:
Testcase:

maric@kanada >uname -a
SunOS kanada 5.8 Generic_108528-16 sun4u sparc SUNW,Ultra-5_10

maric@kanada >cat test.C
class enclosing
{
public:
  enclosing (void);

protected:
  static int i;
  class nested {public: void f(){i=0;}};
};

this code compiles without error and without warnings.
According to ISO/IEC 14882 (C++ Standard) enclosing::nested::f() as a member of nested should not have special access to i which is a protected member of enclosing.

Output from gcc 2.95:

maric@kanada >gcc -Wall -v -c -o /dev/null test.C
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/specs
gcc version 2.95.2 19991024 (release)
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/cpp -lang-c++ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -Wall -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) test.C /var/tmp/ccZAIybg.ii
GNU CPP version 2.95.2 19991024 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../include/g++-3
 /usr/local/include
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/../../../../sparc-sun-solaris2.8/include
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
 /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.2/cc1plus /var/tmp/ccZAIybg.ii -quiet -dumpbase test.cc -Wall -version -o /var/tmp/ccCBs8Iq.s
GNU C++ version 2.95.2 19991024 (release) (sparc-sun-solaris2.8) compiled by GNU C version 2.95.2 19991024 (release).
 /usr/ccs/bin/as -V -Qy -s -o /dev/null /var/tmp/ccCBs8Iq.s
/usr/ccs/bin/as: Sun WorkShop 6 99/08/18


gcc 3.2 on Solaris 2.6 shows the same behaviour









>How-To-Repeat:
compile the following testcase:

class enclosing
{
public:
  enclosing (void);

protected:
  static int i;
  class nested {public: void f(){i=0;}};
};
>Fix:

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


             reply	other threads:[~2002-12-04 18:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-04 10:36 Boris.Maric [this message]
2002-12-04 11:03 bangerth

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=20021204183344.23116.qmail@sources.redhat.com \
    --to=boris.maric@consol.de \
    --cc=gcc-gnats@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).