This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/6644: g++ allows illegal access of private class members



>Number:         6644
>Category:       c++
>Synopsis:       g++ allows illegal access of private class members
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Mon May 13 05:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Volker Reichelt
>Release:        gcc 3.0.x, gcc 3.1 20020510 (prerelease)
>Organization:
>Environment:
mips-sgi-irix6.5, i686-pc-linux-gnu
>Description:
The following code compiles fine, although "a.i" shouldn't
be accessible in "B" ("i" is private in "A" and "B" is not
a friend of "A"):

-------------------------snip here------------------------
class A
{
    int i;

    struct B { void foo () { A a; a.i; } };
};
-------------------------snip here------------------------

It's a regression from 2.95.x which correctly issues an
error message.
>How-To-Repeat:
g++ -c Bug.cpp
or even
g++ -pedantic -c Bug.cpp
>Fix:

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]