Example of valid code from the standard (10.2.7 Member name lookup [class.member.lookup]) compiled with command: "g++ -std=c++11 main.cpp && ./a.out" on Linux compiler version: g++ (GCC) 6.1.0 Copyright (C) 2016 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. =================================================================================== struct A { int x; }; // S(x,A) = { { A::x }, { A } } struct B { float x; }; // S(x,B) = { { B::x }, { B } } struct C: public A, public B { }; // S(x,C) = { invalid, { A in C, B in C } } struct D: public virtual C { }; // S(x,D) = S(x,C) struct E: public virtual C { char x; }; // S(x,E) = { { E::x }, { E } } struct F: public D, public E { }; // S(x,F) = S(x,E) int main() { F f; f.x = 0; // OK, lookup finds E::x } =================================================================================== Error message: main.cpp: In function 'int main()': main.cpp:11:6: error: request for member 'x' is ambiguous f.x = 0; // OK, lookup finds E::x ^ main.cpp:2:18: note: candidates are: float B::x struct B { float x; }; // S(x,B) = { { B::x }, { B } } ^ main.cpp:1:16: note: int A::x struct A { int x; }; // S(x,A) = { { A::x }, { A } } ^
It's important to note that if you switch the order of inheritance in struct F ( instead of: "struct F: public D, public E { };" use: "struct F: public E, public F { };" ) this example compiled without an error, even though the standard say that the order of derivation is not significant (10.1.2 Multiple base classes [class.mi])
*** Bug 92890 has been marked as a duplicate of this bug. ***