@@ -1838,6 +1838,10 @@ cxx_eval_binary_expression (const constexpr_ctx *ctx, tree t,
&& (null_member_pointer_value_p (lhs)
|| null_member_pointer_value_p (rhs)))
r = constant_boolean_node (!is_code_eq, type);
+ else if (TREE_CODE (lhs) == PTRMEM_CST)
+ lhs = cplus_expand_constant (lhs);
+ else if (TREE_CODE (rhs) == PTRMEM_CST)
+ rhs = cplus_expand_constant (rhs);
}
if (r == NULL_TREE)
new file mode 100644
@@ -0,0 +1,13 @@
+// PR c++/71896
+// { dg-do compile { target c++11 } }
+
+struct Foo {
+ int x;
+};
+
+constexpr bool compare(int Foo::*t) { return t == &Foo::x; }
+
+constexpr bool b = compare(&Foo::x);
+
+#define SA(X) static_assert ((X),#X)
+SA(b);