Page MenuHomePhabricator

[secp256k1] refactor: Use array initialization for unterminated strings
ClosedPublic

Authored by PiRK on Jan 30 2026, 16:11.

Details

Summary

The previous code is correct and harmless to initialize an array with a
non-terminated character sequence using a string literal.

However, it requires exactly specifying the array size, which can be
cumbersome.

Also, GCC-15 may issue the -Wunterminated-string-initialization warning.
[1]

Fix both issues by using array initialization. This refactoring commit
does not change behavior.

[1] Example warning:

src/modules/schnorrsig/main_impl.h:48:46: error: initializer-string for array of 'unsigned char' is too long [-Werror=unterminated-string-initialization]

48 | static const unsigned char bip340_algo[13] = "BIP0340/nonce";
   |                                              ^~~~~~~~~~~~~~~

This is a partial backport of secp256k1#1583
https://github.com/bitcoin-core/secp256k1/pull/1583/changes/fa67b6752d8ba3e4c41f6c36b1c6b94a21770419

Test Plan

ninja check-secp256k1

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Jan 30 2026, 16:11

I ran into these errors while backporting Github Actions related PRs, that depends on GCC15

https://github.com/PiRK/secp256k1/actions/runs/21521726257/job/62014494080#step:4:219

Might need to add more instances depending on the results of pushing this to github actions

PiRK retitled this revision from refactor: Use array initialization for unterminated strings to [secp256k1] refactor: Use array initialization for unterminated strings.Jan 30 2026, 16:50
This revision is now accepted and ready to land.Jan 30 2026, 21:13