[Bug c/64439] Incorrect location of -Wunused-value or false negative

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Dec 16 13:08:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64439

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |mpolacek at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This seems to be on purpose since ancient

commit 9dfbe515a74532d27db0a3d11a9163c4e571aa9b
Author: kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Sun Feb 2 12:37:24 1992 +0000

    Initial revision


    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@268
138bc75d-0d04-0410-961f-82ee72b054a4

warn_if_unused_value has:
 1480     case TRUTH_ORIF_EXPR:
 1481     case TRUTH_ANDIF_EXPR:
 1482       /* In && or ||, warn if 2nd operand has no side effect.  */
 1483       exp = TREE_OPERAND (exp, 1);
 1484       goto restart;


As for the discrepancy in Comment 1, the problem is that "a" in "((b = 0) != 0)
&& a" has the location of "&&".  That's because when creating op1 of the
TRUTH_AND_EXPR via c_objc_common_truthvalue_conversion, we use the location of
the TRUTH_AND_EXPR itself--PARM_DECLs don't carry a location.  But that is a
related issue.  So I think I'll close this bug.  Please feel free to reopen.


More information about the Gcc-bugs mailing list