[Bug c++/60829] Illegal access to private base of public base granted.

trippels at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Apr 12 06:35:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60829

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-04-12
                 CC|                            |trippels at gcc dot gnu.org
   Target Milestone|---                         |4.7.5
     Ever confirmed|0                           |1
      Known to fail|                            |4.7.3, 4.8.3, 4.9.0

--- Comment #3 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
markus@x4 /tmp % cat test.ii
class A
{
public:
  int a;
};

class B : private A
{
};

class C : public A
{
};

class D : public B, public C
{
  D () { B::a = 0; }
};

markus@x4 /tmp % g++ -c test.ii
markus@x4 /tmp % clang++ -c test.ii
test.ii:17:13: error: cannot cast 'B' to its private base class 'A'
  D () { B::a = 0; }
            ^
test.ii:7:11: note: declared private here
class B : private A
          ^~~~~~~~~
test.ii:17:13: error: 'a' is a private member of 'A'
  D () { B::a = 0; }
            ^
test.ii:7:11: note: constrained by private inheritance here
class B : private A
          ^~~~~~~~~
test.ii:4:7: note: member is declared here
  int a;
      ^
2 errors generated.



More information about the Gcc-bugs mailing list