[Bug c++/67395] It is possible to override c++ access control in case of indirect inheritance

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Dec 28 07:35:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67395

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid,
                   |                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-12-28
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think it is choosing the wrong v.
Here is a testcase which shows why:
#include <iostream>
using namespace std;
class a {
        protected:
        int v{0};
};

class b : public a { };
class c : private a { };
class d : public c, public b {
        public:
        d() {
                cout << b::a::v << "\n";
        }
};

int main() {
d testcase{};
}

--- CUT ---

Here I qualify which a I am talking about but GCC still says:
t99.cc: In constructor ‘d::d()’:
t99.cc:13:17: error: ‘a’ is an ambiguous base of ‘d’
   cout << b::a::v << "\n";
                 ^

Confirmed.


More information about the Gcc-bugs mailing list