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]

c++/1616: gcc allows access to private variable in enclosing scope



>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:

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