use of bitwise '|' with boolean operands
- Dominant language
- C++
- Stars
- 262
- Forks
- 110
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
Research direction
Inspect XMPCore/source/ParseRDF.cpp around line 389 and XMPFiles/source/FileHandlers/P2_Handler.cpp around lines 161 and 235. Reproduce with clang 14 and -Wbitwise-instead-of-logical, then verify the warning is no longer emitted at those locations and the affected build succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100