public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/10016: g++ allows access to static private class members if initialized
@ 2003-03-10 15:49 bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: bangerth @ 2003-03-10 15:49 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, thor

Synopsis: g++ allows access to static private class members if initialized

State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Mon Mar 10 15:49:42 2003
State-Changed-Why:
    Confirmed. However, already fixed in 3.4:
    
    g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc
    x.cc: In member function `int B::MyFoo()':
    x.cc:4: error: `int A::foo' is private
    x.cc:10: error: within this context

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10016


^ permalink raw reply	[flat|nested] 2+ messages in thread

* c++/10016: g++ allows access to static private class members if initialized
@ 2003-03-10 14:26 thor
  0 siblings, 0 replies; 2+ messages in thread
From: thor @ 2003-03-10 14:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         10016
>Category:       c++
>Synopsis:       g++ allows access to static private class members if initialized
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 10 14:26:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Thomas Richter
>Release:        g++ (GCC) 3.2
>Organization:
>Environment:
Linux i386
>Description:
g++ accepts the following code without generating a warning or an error, though it should warn about trying to access the private member "foo" of class A:

/* snip */

class A {
  static int foo;
};
int A::foo = 42;

class B : public A {
public:
  int MyFoo(void) 
  { 
    return foo; 
  }
};

int main(int argc,char **argv)
{
  class B b;

  return b.MyFoo();
}
>How-To-Repeat:
Save the above program as "foo.cpp", then compile as follows:

$ g++ -Wall foo.cpp

g++ will compile the program without generating an error or a warning, even though A::foo is private within B::MyFoo. g++ will warn if the initializer for A::foo is moved out of sight.
>Fix:

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-03-10 15:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-10 15:49 c++/10016: g++ allows access to static private class members if initialized bangerth
  -- strict thread matches above, loose matches on Subject: below --
2003-03-10 14:26 thor

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).