adobe/XMP-Toolkit-SDK

use of bitwise '|' with boolean operands

hfiguiere opened this issue · 0 comments

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