Skip to content

tests: Fix function pointer initialization C89 error in ellswift tests#1837

Open
mllwchrry wants to merge 1 commit intobitcoin-core:masterfrom
mllwchrry:ellswift-c89-compliance
Open

tests: Fix function pointer initialization C89 error in ellswift tests#1837
mllwchrry wants to merge 1 commit intobitcoin-core:masterfrom
mllwchrry:ellswift-c89-compliance

Conversation

@mllwchrry
Copy link

Fixes a C89 pedantic compliance error in src/modules/ellswift/tests_impl.h where function pointer array initialization is not allowed at declaration time.

This error was exposed while I was testing the improved test coverage in CI. The initial plan was to simplify the configuration of modules in CI by enabling all modules by default and testing the disabling of each module independently.

Error: src/modules/ellswift/tests_impl.h:442:110: error: initializer element is not computable at load time [-Wpedantic].

The error occurred when running the x86_64_debian GitHub Actions CI job, which uses GCC 16 (snapshot) with strict flags (-std=c89 -pedantic -pedantic-errors -Werror). See this action run for reference: https://github.com/mllwchrry/secp256k1/actions/runs/23301905657/job/67769464566.

The fix uses if/else to assign function pointers after declaration, matching the pattern already used in the same file.

While this is a minor C89 compliance issue, it blocks the potential CI simplification.

@real-or-random
Copy link
Contributor

I was wondering why we hadn't noticed this earlier. Apparently this happens only with -O0. (Try here)

"Constant expressions" is a weird corner of C, and this here indeed may depend on how you interpret the C89 standard. Anyway, this issue would go away if we switched to C99 because non-constant expressions would just be allowed there in array initializers.

Copy link
Contributor

@real-or-random real-or-random left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK b84635e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants