You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clang 14 now raises a warning when bitwise operations are performed with boolean operands
...
[ 15%] Building C object trezor-crypto/CMakeFiles/TrezorCrypto.dir/crypto/ed25519-donna/modm-donna-32bit.c.o
/home/pierre/dev/wallet-core/trezor-crypto/crypto/sha3.c:291:7: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]
if (IS_ALIGNED_64(msg)) {
^~~~~~~~~~~~~~~~~~
/home/pierre/dev/wallet-core/trezor-crypto/crypto/sha3.c:29:55: note: expanded from macro 'IS_ALIGNED_64'
#define IS_ALIGNED_64(p) (0 == (7 & ((const char*)(p) - (const char*)0)))
^ ~~~~~~~~~~~~~~
1 error generated.
make[3]: *** [trezor-crypto/CMakeFiles/TrezorCrypto.dir/build.make:277: trezor-crypto/CMakeFiles/TrezorCrypto.dir/crypto/sha3.c.o] Error 1
make[3]: *** Waiting for unfinished jobs....
/home/pierre/dev/wallet-core/trezor-crypto/crypto/bignum.c:274:10: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
assert((cond == 1) | (cond == 0));
^~~~~~~~~~~~~~~~~~~~~~~~~
||
/usr/include/assert.h:109:11: note: expanded from macro 'assert'
if (expr) \
^~~~
/home/pierre/dev/wallet-core/trezor-crypto/crypto/bignum.c:274:10: note: cast one or both operands to int to silence this warning
/home/pierre/dev/wallet-core/trezor-crypto/crypto/bignum.c:293:10: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
assert((cond == 1) | (cond == 0));
^~~~~~~~~~~~~~~~~~~~~~~~~
||
/usr/include/assert.h:109:11: note: expanded from macro 'assert'
if (expr) \
^~~~
/home/pierre/dev/wallet-core/trezor-crypto/crypto/bignum.c:293:10: note: cast one or both operands to int to silence this warning
2 errors generated.
I tried to follow the instructions in trezor-crypto/setup_from_upstream.sh to update trezor-crypto, but it is a bit too complex a solution just to fix a simple compiler warning. If you want to use this solution, you will probably want someone you trust to do the update, because it makes for a very large PR to review.
The simple alternative is too pick just the two relevant commits.
On my side, I will simply revert to clang 13 to work around the issue:
Describe the bug
Clang 14 now raises a warning when bitwise operations are performed with boolean operands
To Reproduce
Install clang 14 and try to build.
Expected behavior
Fix build to work with clang 14
Additional context
See a similar error recently fixed by bitcoin core:
bitcoin/bitcoin#23573
And another one in libsecp256k1:
bitcoin-core/secp256k1#1009
The solution is to cast the operands to int. This has been done upstream (in two steps, because the first commit was the wrong solution):
trezor/trezor-firmware@0c48217
trezor/trezor-firmware@d1d3558
I tried to follow the instructions in
trezor-crypto/setup_from_upstream.sh
to update trezor-crypto, but it is a bit too complex a solution just to fix a simple compiler warning. If you want to use this solution, you will probably want someone you trust to do the update, because it makes for a very large PR to review.The simple alternative is too pick just the two relevant commits.
On my side, I will simply revert to clang 13 to work around the issue:
The text was updated successfully, but these errors were encountered: