This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/1616: gcc allows access to private variable in enclosing scope
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/1616: gcc allows access to private variable in enclosing scope
- From: wolfgang dot bangerth at iwr dot uni-heidelberg dot de
- Date: 11 Jan 2001 12:05:48 -0000
- Reply-To: wolfgang dot bangerth at iwr dot uni-heidelberg dot de
>Number: 1616
>Category: c++
>Synopsis: gcc allows access to private variable in enclosing scope
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jan 11 04:06:04 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Wolfgang Bangerth
>Release: unknown-1.0
>Organization:
>Environment:
Sun, Linux
>Description:
this compiles fine, to my astonishment:
class X {
static int i;
struct Y {
int f() { return i; };
};
};
Note that X::Y::f accesses the (private) static variable from X, which I
think it shouldn't be able to do (why is this variable visible in
the scope of X::Y::f at all?). I always thought, nested scopes are not
by default friends of the enclosing one (after all, f() can't call private
functions in X as well).
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: