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.