https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46283
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- ((a *)0)->foo::x() ((T *)0)->foo::x() Both are those are undefined because you are calling a method of a NULL pointer. (In reply to Andrew Pinski from comment #1) > I think the code should be rejected. Here is what Comeau online says: > "ComeauTest.c", line 14: error: ambiguous class member reference -- type > "b::foo" > (declared at line 4) used in preference to type "a::foo" (declared > at line 10) And clang rejects this: <source>:14:41: error: lookup of 'foo' in member access expression is ambiguous void b::go() { printf("%i\n", ((a *)0)->foo::x()); } ^ <source>:10:13: note: lookup in the object type 'a' refers here typedef b foo; ^ <source>:4:20: note: lookup from the current scope refers here typedef struct a foo; ^