This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/45770] global access allowance exceeds that of derived class
- From: "MichieldeB at aim dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 26 Sep 2010 18:14:26 +0000
- Subject: [Bug c++/45770] global access allowance exceeds that of derived class
- Auto-submitted: auto-generated
- References: <bug-45770-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45770
MichieldeB at aim dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
--- Comment #4 from MichieldeB at aim dot com 2010-09-26 18:14:26 UTC ---
My last counterexample was invalid, sorry. Furthermore, the problem does not
seem a template problem. I now have an example where the local object has lower
rights than the inherited object, thus no access inheritance for the local.
// g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
// Copyright (C) 2009 Free Software Foundation, Inc.
// This is free software; see the source for copying conditions. There is NO
// warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
class A
{
friend class B;
public:
A(int i) { a = i; }
protected:
A(int i, int j) { a = i ^ j; }
private:
A() { a = 0; }
int a;
};
class B : private A // making protected will allow local variables A below
{
public:
B(int i) : A () { a = i >> 1; b = i & 1; }
private:
bool b;
};
class C : public B
{
public:
C() : B(4) { ::A foo(3); } // functions of B may have local variables ::A
// but not A
};
class D : public A
{
friend class D;
D(int i, int j) : A(i,j)
{
A d(i,j); // friend class D of class D has no inherited rights here
// note that friends do not have inherited objects in general
}
};
main () { A bar(3); } // main may have local variables A