Implementation divergence for a program with multiple inheritance and using-declaration with a different access specifier than the original declaration
Is the following program well-formed or poorly 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 give different results. Klang rejects it, and GCC accepts it:
- http://melpon.org/wandbox/permlink/SqSEtcYaR72A4eNS (Clan Disclaimer)
- http://melpon.org/wandbox/permlink/N3ORCxG8qnU6Zmeq (GCC trick)
I think the program is well formed (and therefore this clan has a bug for it to fail) http://eel.is/c++draft/class.paths#1 but I'm not sure:
If a name can be reached in multiple paths across multiple inheritance graphs, access is the path that gives the most access.
+3
source to share
No one has answered this question yet
Check out similar questions: