GCC 12 rejects a constexpr function that calls a non-constexpr one
PitfallVerified 5 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
The GCC 12 build (docker-test-gcc12) fails, while Clang and newer compilers accept the same code. DataType::fixed_size and its helpers (TypeParams::fixed, fixed_size) were the sites.
Cause#
A constexpr caller used a function that was not marked constexpr; only GCC 12 rejects it.
Fix#
Mark the called function and its helpers constexpr.
Evidence#
Fixed in commit 5a12a75a (fix(build): build and test on GCC 12).
Also found by searching
- GCC 12 rejects constexpr function calling a non-constexpr one
- constexpr DataType::fixed_size GCC 12 build error
- build passes on Clang but fails only in the GCC 12 container for constexpr
- mark helper functions constexpr for GCC 12