https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70248
--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> --- In gcc/cp/typeck.c:cp_build_binary_op this warning should be an error during constant evaluation for EQ_EXPR and NE_EXPR: if (complain & tf_warning) { tree stripped_orig_op0 = tree_strip_any_location_wrapper (orig_op0); tree stripped_orig_op1 = tree_strip_any_location_wrapper (orig_op1); if ((TREE_CODE (stripped_orig_op0) == STRING_CST && !integer_zerop (cp_fully_fold (op1))) || (TREE_CODE (stripped_orig_op1) == STRING_CST && !integer_zerop (cp_fully_fold (op0)))) warning_at (location, OPT_Waddress, "comparison with string literal results in " "unspecified behavior"); } And this one for rel ops and spaceships: if (TREE_CODE (orig_op0) == STRING_CST || TREE_CODE (orig_op1) == STRING_CST) { if (complain & tf_warning) warning_at (location, OPT_Waddress, "comparison with string literal results " "in unspecified behavior"); } That only handles the string literals cases though, we also need to reject pointers to distinct objects at the same places.