* constexpr.c (cxx_eval_binary_expression): Handle comparison
between lowered and unlowered PTRMEM_CST.
From-SVN: r238562
2016-07-21 Jason Merrill <jason@redhat.com>
+ PR c++/71896
+ * constexpr.c (cxx_eval_binary_expression): Handle comparison
+ between lowered and unlowered PTRMEM_CST.
+
PR c++/65168
* typeck.c (cp_truthvalue_conversion): Compare pointers to nullptr.
Don't set c_inhibit_evaluation_warnings.
&& (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)
--- /dev/null
+// 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);