I get these warnings with clang++ v13 onwards. git blame suggests these are not new.
clang++-16 -Ilib -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2 -pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -g -std=gnu++0x -pipe -c -o lib/checkcondition.o lib/checkcondition.cpp
lib/checkcondition.cpp:413:17: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]
if (tok && (diag(tok) | diag(tok->astParent())))
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
||
lib/checkcondition.cpp:413:17: note: cast one or both operands to int to silence this warning
lib/checkcondition.cpp:507:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
if (diag(tok1) & diag(tok2))
^~~~~~~~~~~~~~~~~~~~~~~
&&
lib/checkcondition.cpp:507:9: note: cast one or both operands to int to silence this warning
lib/checkcondition.cpp:569:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
if (diag(ifCond) & diag(elseIfCond))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&&
lib/checkcondition.cpp:569:9: note: cast one or both operands to int to silence this warning
lib/checkcondition.cpp:831:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
if (diag(tok1) & diag(tok2))
^~~~~~~~~~~~~~~~~~~~~~~
&&
lib/checkcondition.cpp:831:9: note: cast one or both operands to int to silence this warning
lib/checkcondition.cpp:846:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
if (diag(tok1) & diag(tok2))
^~~~~~~~~~~~~~~~~~~~~~~
&&
lib/checkcondition.cpp:846:9: note: cast one or both operands to int to silence this warning
lib/checkcondition.cpp:861:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
if (diag(cond1) & diag(cond2))
^~~~~~~~~~~~~~~~~~~~~~~~~
&&
lib/checkcondition.cpp:861:9: note: cast one or both operands to int to silence this warning
6 warnings generated.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I get these warnings with clang++ v13 onwards. git blame suggests these are not new.
clang++-16 -Ilib -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2 -pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -g -std=gnu++0x -pipe -c -o lib/checkcondition.o lib/checkcondition.cpp
lib/checkcondition.cpp:413:17: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]
if (tok && (diag(tok) | diag(tok->astParent())))
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
||
lib/checkcondition.cpp:413:17: note: cast one or both operands to int to silence this warning
lib/checkcondition.cpp:507:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
if (diag(tok1) & diag(tok2))
^~~~~~~~~~~~~~~~~~~~~~~
&&
lib/checkcondition.cpp:507:9: note: cast one or both operands to int to silence this warning
lib/checkcondition.cpp:569:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
if (diag(ifCond) & diag(elseIfCond))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
&&
lib/checkcondition.cpp:569:9: note: cast one or both operands to int to silence this warning
lib/checkcondition.cpp:831:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
if (diag(tok1) & diag(tok2))
^~~~~~~~~~~~~~~~~~~~~~~
&&
lib/checkcondition.cpp:831:9: note: cast one or both operands to int to silence this warning
lib/checkcondition.cpp:846:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
if (diag(tok1) & diag(tok2))
^~~~~~~~~~~~~~~~~~~~~~~
&&
lib/checkcondition.cpp:846:9: note: cast one or both operands to int to silence this warning
lib/checkcondition.cpp:861:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
if (diag(cond1) & diag(cond2))
^~~~~~~~~~~~~~~~~~~~~~~~~
&&
lib/checkcondition.cpp:861:9: note: cast one or both operands to int to silence this warning
6 warnings generated.
Spontanously I think that we sometimes do not want to short circuit. If you want to short circuit then use && and || otherwise use & and |.
How do you build? With the normal Makefile? Maybe you somehow need to disable that warning.
In the code examples you show however.. it seems that a short circuit might make sense. The diag functions seems non-trivial.