adobe / XMP-Toolkit-SDK

The XMP Toolkit allows you to integrate XMP functionality into your product or solution
BSD 3-Clause "New" or "Revised" License
205 stars 83 forks source link

use of bitwise '|' with boolean operands #59

Open hfiguiere opened 2 years ago

hfiguiere commented 2 years ago

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