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

            Bug ID: 88266
           Summary: nonsense warning about parentheses for comparison
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jason.kraftch...@cd-adapco.com
  Target Milestone: ---

For this code compiled with -Wall:

  bool xnor( bool a, bool b, bool c, bool d )
    { return a != b != c != d; }

I get these warnings:

  /tmp/xnor.cc: In function ‘bool xnor(bool, bool, bool, bool)’:
  /tmp/xnor.cc:2:14: warning: suggest parentheses around comparison in operand
of ‘!=’ [-Wparentheses]
     { return a != b != c != d; }
              ~~^~~~
  /tmp/xnor.cc:2:19: warning: suggest parentheses around comparison in operand
of ‘!=’ [-Wparentheses]
     { return a != b != c != d; }
              ~~~~~~~^~~~

The order of evaluation of these comparisons doesn't matter, so parentheses add
nothing.  One could even argue that adding them would be detrimental because it
gives the false impression that the order matters.

Reply via email to