public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: chris@pennasoft.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/9061: Improper access granted to protected typedef from nested member of derived class
Date: Thu, 26 Dec 2002 12:46:00 -0000	[thread overview]
Message-ID: <20021226204302.5992.qmail@sources.redhat.com> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]


>Number:         9061
>Category:       c++
>Synopsis:       Improper access granted to protected typedef from nested member of derived class
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 26 12:46:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     chris@pennasoft.com
>Release:        2.95.4
>Organization:
>Environment:
FreeBSD topperwein.pennasoft.com 4.7-STABLE FreeBSD 4.7-STABLE #0: Wed Dec  4 15:59:17 EST 2002     behanna@topperwein.pennasoft.com:/raid0/stable/usr/obj/raid0/stable/usr/src/sys/TOPPERWEIN  i386
>Description:
Consider the following:

class Parent {
protected:
    typedef int MyInt;
};

class Child: public Parent {
protected:
    class Nested {
    public:
        inline MyInt myfunc() { return 0; }
    };
};

class Nested is not a derived class of class Parent, and thus should not have access to any protected members of class Parent, per the 1997 C++ draft standard, section 11.8, paragraph 1 (see http://anubis.dkuug.dk/jtc1/sc22/open/n2356/access.html ).

g++ version 2.95.4 allows the above construct.  By way of contrast, Sun's Forté C++ compiler, version 6.2, does not, and issues the complaint:

"prot.C", line 10: Error: Parent::MyInt is not accessible from Child::Nested.
1 Error(s) detected.
>How-To-Repeat:
Save the code example as prot.C and compile it as follows:

g++ -c prot.C
>Fix:

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


             reply	other threads:[~2002-12-26 20:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-26 12:46 chris [this message]
2003-01-06 22:40 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=20021226204302.5992.qmail@sources.redhat.com \
    --to=chris@pennasoft.com \
    --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).