c++/6644: g++ allows illegal access of private class members
reichelt@igpm.rwth-aachen.de
reichelt@igpm.rwth-aachen.de
Mon May 13 05:26:00 GMT 2002
>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:
More information about the Gcc-bugs
mailing list