This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64877] strange warning message from -Waddress
- From: "manu at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 31 Jan 2015 16:09:36 +0000
- Subject: [Bug c++/64877] strange warning message from -Waddress
- Auto-submitted: auto-generated
- References: <bug-64877-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64877
--- Comment #5 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
And just for the sake of completion, the warning we trigger is:
else if (((code0 == POINTER_TYPE || TYPE_PTRDATAMEM_P (type0))
&& null_ptr_cst_p (op1))
/* Handle, eg, (void*)0 (c++/43906), and more. */
|| (code0 == POINTER_TYPE
&& TYPE_PTR_P (type1) && integer_zerop (op1)))
{
if (TYPE_PTR_P (type1))
result_type = composite_pointer_type (type0, type1, op0, op1,
CPO_COMPARISON, complain);
else
result_type = type0;
if (TREE_CODE (op0) == ADDR_EXPR
B => && decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0)))
{
if ((complain & tf_warning)
&& c_inhibit_evaluation_warnings == 0)
warning (OPT_Waddress, "the address of %qD will never be
NULL",
TREE_OPERAND (op0, 0));
}
}
It could be enough to test decl_with_nonnull_addr_p (TREE_OPERAND (op0, 0)) to
avoid building !op0.pfn when not needed.