This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/60759] improve -Wlogical-op
- 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: Tue, 17 Jun 2014 10:33:52 +0000
- Subject: [Bug c/60759] improve -Wlogical-op
- Auto-submitted: auto-generated
- References: <bug-60759-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60759
Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-06-17
Summary|-Wlogical-op should perhaps |improve -Wlogical-op
|warn about two-way implicit |
|conversions |
Ever confirmed|0 |1
--- Comment #4 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
GCC's -Wlogical-op warns for this:
pr60759.c:6:12: warning: logical âorâ applied to non-boolean constant
[-Wlogical-op]
return y || 3;
^
However, GCC does not warn when both operands are constants or neither is a
constant. I think it is clear that it should warn for the former case. The
conditions at which it should warn are the same (it warns even if the result is
used in a boolean context).
The latter case is more controversial. Moreover, in this case the context is
significant:
int a = foo(1) || foo(2); // warn
bool a = foo(1) || foo(2); // do NOT warn
Someone would need to check how much code will be wrongly warned and how to
minimize the amount of false positives.