[Bug c++/63519] missing Wparenthesis warning for x binary_op bool ?:

egallager at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Aug 25 16:32:00 GMT 2017


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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-08-25
                 CC|                            |egallager at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
g++ now prints a warning from -Wint-in-bool-context for it:

$ /usr/local/bin/g++ -c -Wall -Wextra -pedantic 63519.cc
63519.cc: In function ‘int foo(bool, int, int, int)’:
63519.cc:3:11: warning: ‘*’ in boolean context, suggest ‘&&’ instead
[-Wint-in-bool-context]
  return x * a ? y : z;
         ~~^~~
$

Confirming that a warning from -Wparentheses is still missing though. Also the
-Wint-in-bool-context one could do better and add a fix-it hint, seeing as it
already has a suggestion in the message.


More information about the Gcc-bugs mailing list