[28.x] build: suppress -Wunterminated-string-initialization in secp256k1 #32484

pull fanquake wants to merge 1 commits into bitcoin:28.x from fanquake:28_suppress_unterm_string_init changing 1 files +3 −0
  1. fanquake commented at 4:18 pm on May 13, 2025: member

    Suppress -Wunterminated-string-initialization warnings from GCC 15, like:

     0In file included from src/secp256k1.c:830:
     1src/modules/schnorrsig/main_impl.h:48:46: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (14 chars into 13 available) [-Wunterminated-string-initialization]
     2   48 | static const unsigned char bip340_algo[13] = "BIP0340/nonce";
     3      |                                              ^~~~~~~~~~~~~~~
     4In file included from src/tests_exhaustive.c:28:
     5src/testrand_impl.h: In function ‘testrand_seed’:
     6src/testrand_impl.h:21:45: warning: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (20 chars into 19 available) [-Wunterminated-string-initialization]
     7   21 |     static const unsigned char PREFIX[19] = "secp256k1 test init";
     8      |                                             ^~~~~~~~~~~~~~~~~~~~~
     9src/modules/ellswift/tests_impl.h:411:53: warning: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (27 chars into 26 available) [-Wunterminated-string-initialization]
    10  411 |         static const unsigned char bip324_tag[26] = "bip324_ellswift_xonly_ecdh";
    11      |                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

    This was fixed upstream in https://github.com/bitcoin-core/secp256k1/pull/1583, so only relevant for 28.x and later. The code is fine, but the warnings may break builds under -Werror, leave users wondering if there is a real issue etc.

  2. DrahtBot commented at 4:18 pm on May 13, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32484.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Stale ACK hebasto

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Backport on May 13, 2025
  4. theuni commented at 4:49 pm on May 13, 2025: member

    Hmm, my first thought was just to backport the “fix” instead, but I guess we’ve never really backported secp changes for the sake of keeping in sync.

    Either way, in this case I agree it’s simple/safe enough to just suppress the warning for 28.x.

  5. hebasto approved
  6. hebasto commented at 4:53 pm on May 13, 2025: member
    ACK 5c8a55f917d089c8bdf5f59195116d9201c597e7, tested on Ubuntu 25.04 with GCC-15.
  7. fanquake added this to the milestone 28.2 on May 13, 2025
  8. DrahtBot added the label CI failed on May 13, 2025
  9. [28.x] build: suppress -Wunterminated-string-initialization in secp
    Suppress `-Wunterminated-string-initialization` warnings from GCC 15,
    like:
    ```bash
    In file included from src/secp256k1.c:830:
    src/modules/schnorrsig/main_impl.h:48:46: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (14 chars into 13 available) [-Wunterminated-string-initialization]
       48 | static const unsigned char bip340_algo[13] = "BIP0340/nonce";
          |                                              ^~~~~~~~~~~~~~~
    In file included from src/tests_exhaustive.c:28:
    src/testrand_impl.h: In function ‘testrand_seed’:
    src/testrand_impl.h:21:45: warning: initializer-string for array of ‘unsigned char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (20 chars into 19 available) [-Wunterminated-string-initialization]
       21 |     static const unsigned char PREFIX[19] = "secp256k1 test init";
          |                                             ^~~~~~~~~~~~~~~~~~~~~
    ```
    
    This was fixed upstream in
    https://github.com/bitcoin-core/secp256k1/pull/1583.
    7fc15db5f9
  10. fanquake force-pushed on May 16, 2025
  11. fanquake commented at 2:12 pm on May 16, 2025: member
    Changed this, as the prior approach would warn under Clang.
  12. maflcko commented at 3:35 pm on May 16, 2025: member
    An alternative would be to just ignore the warning? CI on 28.x isn’t using gcc 15 and users aren’t really expected to compile with werror?
  13. fanquake commented at 3:42 pm on May 16, 2025: member
    We could also do that. I guess it depends where we expect this branch to be compiled. Any downstream CIs, build systems, packagers etc may be turning warnings into errors. It doesn’t seem bad for us to suppress known non-issues.

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-05-29 18:12 UTC

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