https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64877
Paolo Carlini <paolo.carlini at oracle dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|strange warning message |[5 Regression] strange |from -Waddress |warning message from | |-Waddress --- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> --- Thanks Manuel for the analysis. Indeed, now -Waddress is much more general, and those internally generated expressions are causing problems. Thus, following your suggestion, I would propose something like the below, which I'm finishing testing. Does it look Ok to you? Index: typeck.c =================================================================== --- typeck.c (revision 220306) +++ typeck.c (working copy) @@ -4552,35 +4552,44 @@ cp_build_binary_op (location_t location, The reason for the `!op0.pfn' bit is that a NULL pointer-to-member is any member with a zero PFN and - LSB of the DELTA field is 0. */ + LSB of the DELTA field is 0. Note: avoid generating the + '|| (!op0.pfn && ...)' if !op0.pfn is known to be false. */ - e1 = cp_build_binary_op (location, BIT_AND_EXPR, - delta0, - integer_one_node, - complain); - e1 = cp_build_binary_op (location, - EQ_EXPR, e1, integer_zero_node, - complain); - e2 = cp_build_binary_op (location, BIT_AND_EXPR, - delta1, - integer_one_node, - complain); - e2 = cp_build_binary_op (location, - EQ_EXPR, e2, integer_zero_node, - complain); - e1 = cp_build_binary_op (location, - TRUTH_ANDIF_EXPR, e2, e1, - complain); - e2 = cp_build_binary_op (location, EQ_EXPR, - pfn0, - build_zero_cst (TREE_TYPE (pfn0)), - complain); - e2 = cp_build_binary_op (location, - TRUTH_ANDIF_EXPR, e2, e1, complain); - e1 = cp_build_binary_op (location, - EQ_EXPR, delta0, delta1, complain); - e1 = cp_build_binary_op (location, - TRUTH_ORIF_EXPR, e1, e2, complain); + if (TREE_CODE (pfn0) != ADDR_EXPR + || !decl_with_nonnull_addr_p (TREE_OPERAND (pfn0, 0))) + { + e1 = cp_build_binary_op (location, BIT_AND_EXPR, + delta0, + integer_one_node, + complain); + e1 = cp_build_binary_op (location, + EQ_EXPR, e1, integer_zero_node, + complain); + e2 = cp_build_binary_op (location, BIT_AND_EXPR, + delta1, + integer_one_node, + complain); + e2 = cp_build_binary_op (location, + EQ_EXPR, e2, integer_zero_node, + complain); + e1 = cp_build_binary_op (location, + TRUTH_ANDIF_EXPR, e2, e1, + complain); + e2 = cp_build_binary_op (location, EQ_EXPR, + pfn0, + build_zero_cst (TREE_TYPE (pfn0)), + complain); + e2 = cp_build_binary_op (location, + TRUTH_ANDIF_EXPR, e2, e1, complain); + e1 = cp_build_binary_op (location, + EQ_EXPR, delta0, delta1, complain); + e1 = cp_build_binary_op (location, + TRUTH_ORIF_EXPR, e1, e2, complain); + + } + else + e1 = cp_build_binary_op (location, + EQ_EXPR, delta0, delta1, complain); } else { @@ -4591,17 +4600,22 @@ cp_build_binary_op (location_t location, The reason for the `!op0.pfn' bit is that a NULL pointer-to-member is any member with a zero PFN; the - DELTA field is unspecified. */ + DELTA field is unspecified. Note: avoid generating the + '!op0.pfn ||' if !op0.pfn is known to be false. */ e1 = cp_build_binary_op (location, EQ_EXPR, delta0, delta1, complain); - e2 = cp_build_binary_op (location, - EQ_EXPR, - pfn0, - build_zero_cst (TREE_TYPE (pfn0)), - complain); - e1 = cp_build_binary_op (location, - TRUTH_ORIF_EXPR, e1, e2, complain); + if (TREE_CODE (pfn0) != ADDR_EXPR + || !decl_with_nonnull_addr_p (TREE_OPERAND (pfn0, 0))) + { + e2 = cp_build_binary_op (location, + EQ_EXPR, + pfn0, + build_zero_cst (TREE_TYPE (pfn0)), + complain); + e1 = cp_build_binary_op (location, + TRUTH_ORIF_EXPR, e1, e2, complain); + } } e2 = build2 (EQ_EXPR, boolean_type_node, pfn0, pfn1); e = cp_build_binary_op (location,