refactor: Use && in boolean context to avoid compiler warning #1006

pull MarcoFalke wants to merge 1 commits into bitcoin-core:master from MarcoFalke:2111-amp changing 1 files +1 −1
  1. MarcoFalke commented at 3:10 PM on November 8, 2021: none

    This fixes a compiler warning:

    ./src/ecdsa_impl.h:312:12: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
        return !secp256k1_scalar_is_zero(sigr) & !secp256k1_scalar_is_zero(sigs);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                               &&
    
  2. refactor: Use && in boolean context to avoid compiler warning
    This fixes a compiler warning:
    
    ./src/ecdsa_impl.h:312:12: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
        return !secp256k1_scalar_is_zero(sigr) & !secp256k1_scalar_is_zero(sigs);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                               &&
    e24b9ac353
  3. MarcoFalke commented at 3:12 PM on November 8, 2021: none

    I didn't try to reproduce this, but I randomly saw it in logs on a 32-bit compilation with clang-14 (trunk) and some odd compiler flags like -O0.

  4. MarcoFalke commented at 3:23 PM on November 8, 2021: none

    Ah, I see.

    Good thing there are tests.

  5. MarcoFalke closed this on Nov 8, 2021

  6. MarcoFalke deleted the branch on Nov 8, 2021
  7. sipa commented at 3:24 PM on November 8, 2021: contributor

    :)

  8. MarcoFalke commented at 4:42 PM on November 8, 2021: none
  9. sipa commented at 5:26 PM on November 8, 2021: contributor

    If there is a need to silence anything, I think the correct approach is suggested there: cast one of the inputs to & to int.

  10. MarcoFalke cross-referenced this on Nov 9, 2021 from issue refactor: Use (int)&(int) in boolean context to avoid compiler warning by MarcoFalke
  11. real-or-random referenced this in commit 74c34e727b on Nov 9, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-19 07:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me