Is the following program well-formed or ill-formed according to the c++ standard?
struct A { protected: static const int x = 0; };
struct B : A {};
struct C : A { using A::x; };
struct D : B, C {};
int main() { D::x; }
Different compilers gives different results. Clang rejects it and GCC accepts it:
- http://melpon.org/wandbox/permlink/SqSEtcYaR72A4eNS (Clang rejection)
- http://melpon.org/wandbox/permlink/N3ORCxG8qnU6Zmeq (GCC acceptance)
I think that the program is well-formed (and therefore that clang has the bug for rejecting it) by http://eel.is/c++draft/class.paths#1, but i'm not sure:
If a name can be reached by several paths through a multiple inheritance graph, the access is that of the path that gives most access.