Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use of bitwise '|' with boolean operands #59

Open
hfiguiere opened this issue Apr 9, 2022 · 0 comments
Open

use of bitwise '|' with boolean operands #59

hfiguiere opened this issue Apr 9, 2022 · 0 comments

Comments

@hfiguiere
Copy link

Build clang 14 and -Wbitwise-instead-of-logical as a warning

Expected Behaviour

The warning is never emitted

Actual Behaviour

It is emitted:

  CXX      ParseRDF.lo
../../../XMPCore/source/ParseRDF.cpp:389:8: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
                if ( (name[i] < '0') | (name[i] > '9') ) return false;
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                     ||
../../../XMPCore/source/ParseRDF.cpp:389:8: note: cast one or both operands to int to silence this warning
1 error generated.
  CXX      P2_Handler.lo
../../../../XMPFiles/source/FileHandlers/P2_Handler.cpp:161:8: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
                if ( (parentName == "AUDIO") | (parentName == "VOICE") ) {
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                             ||
../../../../XMPFiles/source/FileHandlers/P2_Handler.cpp:161:8: note: cast one or both operands to int to silence this warning
../../../../XMPFiles/source/FileHandlers/P2_Handler.cpp:235:8: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
                if ( (parentName == "AUDIO") | (parentName == "VOICE") ) {
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                             ||
../../../../XMPFiles/source/FileHandlers/P2_Handler.cpp:235:8: note: cast one or both operands to int to silence this warning
2 errors generated.

Note: here it says "error" because I have set it to be an error, but even as a warning it is present.

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Build with clang 14, enable -Wbitwise-instead-of-logical

Platform and Version

clang version 14.0.0 (Fedora 14.0.0-1.fc36)

Sample Code that illustrates the problem

Logs taken while reproducing problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant