[Bug c/32061] (Wlogical-op) wording of warning of constant logicials need improvement

manu at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Feb 11 23:04:00 GMT 2009



------- Comment #3 from manu at gcc dot gnu dot org  2009-02-11 23:04 -------
Confirmed. I have a patch for this for 4.5.

The new wording will say:

warning: logical 'or' applied to non-boolean constant.

Are you satisfied with this?

> 
> BTW, why no warning for this?
>    resp == 0 && 0
> Naturally, all the above constants will hide behind some macros which could
> indicate a real error, hence the value of the warning.

Warning for (x && 0) or (x && 1) would produce hundreds of false positives. We
shouldn't warn about your testcase either.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-02-11 23:04:41
               date|                            |
            Summary|wording of warning of       |(Wlogical-op) wording of
                   |constant logicials need     |warning of constant
                   |improvement                 |logicials need improvement


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32061



More information about the Gcc-bugs mailing list