https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77292
Bug ID: 77292 Summary: Spurious "warning: logical not is only applied to the left hand side of comparison" Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: terra at gnome dot org Target Milestone: --- The warning introduced in bug 62183 is trigger-happy. int foo (int a, int b) { // Make it obvious that these are booleans. a = !!a; b = !!b; return !a == b; } # gcc --version gcc (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # gcc -c -Wall -O2 bbb.c bbb.c: In function ‘foo’: bbb.c:8:13: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses] return !a == b; ^ This is silly and out-right illogical when "a" and "b" are booleans. "!a == b" means the same as "!(a == b)", so the warning is pointing out that I might have meant something else that, upon inspection, is seen to be the same thing. Note: by "boolean" I mean an integer with value 0 or 1.