[Bug c++/17314] Error message wrongly shows declared rather than inherited access

jason at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu May 16 14:07:00 GMT 2013


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

--- Comment #15 from Jason Merrill <jason at gcc dot gnu.org> ---
Yes, that would be an improvement to the diagnostic.  But it seems to me that
there's a deeper issue here: I think both testcases should be ill-formed
because C::C can't form a pointer to its A base in order to try to call its
constructor.  Just as in this testcase:

class A {
protected:
  void g();
};
class B : virtual A { };
class C : public B {
  void f() { ::A::g(); }
};
int main () {
  C c;
}

Here if we could convert 'this' to an A*, we would be OK.  Now, the magic
conversion for vbase construction is special, and the standard doesn't really
say how special; if it has special access (to go along with its special ability
to choose a specific subobject in a hierarchy that might have multiple bases of
the same type), the original testcase should be ok: we're calling a protected
member through a C object, which is fine by the rules for protected access.  If
the constructor doesn't have special access, then it's ill-formed even if the
constructor is public.

I think a core issue is warranted.  But for the mean time, making that change
to the diagnostic would be an improvement.



More information about the Gcc-bugs mailing list