https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71765
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid Status|UNCONFIRMED |NEW Last reconfirmed| |2016-07-05 Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- From the clang bug report: [basic.lookup.classref]p3 says: "If the unqualified-id is ~type-name, the type-name is looked up in the context of the entire postfix-expression. If the type T of the object expression is of a class type C, the type-name is also looked up in the scope of class C. At least one of the lookups shall find a name that refers to (possibly cv-qualified) T." So Richard is right that we should reject it, because lookup for ~A finds the type-name A, but that doesn't refer to B, so it's ill-formed.