Repository navigation
Avoid zero-filling bigint buffers in the slow path (C++26 [[indeterminate]]) - #440
Merged
Merged
Conversation
…nate]]) bigint() : vec() value-initialized its stackvec, zeroing 500 bytes on every construction because stackvec's default constructor was defaulted. Give stackvec a user-provided constructor so that it does not. Add FASTFLOAT_INDETERMINATE ([[indeterminate]] in C++26, otherwise __attribute__((uninitialized))) and apply it to the stackvec/bigint locals of the slow path, which C++26 (P2795R5) and -ftrivial-auto-var-init would otherwise zero-fill. stackvec only reads up to its length, so none of these buffers needs zeroing.
ubuntu-latest now maps to Ubuntu 26.04, whose sudo ignores -E. The setup-alpine v1 action then loses its INPUT_* variables and fails with "INPUT_APK_TOOLS_URL: unbound variable".
jwakely
approved these changes
Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The digit-comparison slow path (numbers with more than 19 significant digits whose rounding Eisel-Lemire cannot decide) puts several 500-byte
stackvecbuffers on the stack. They were being zeroed for nothing:bigint() : vec()value-initializedvec. Becausestackvec's default constructor was= default, this zeroed all 500 bytes on every construction, in every C++ standard.-ftrivial-auto-var-init=zeroin earlier modes. That adds memsets forzandziinlong_mul(zion every pass through the loop) and for the bigints indigit_comparison.h.stackveconly reads up tolength, so none of these buffers needs zeroing.Changes:
FASTFLOAT_INDETERMINATE:[[indeterminate]]in C++26 when the compiler supports it, otherwise__attribute__((uninitialized)), otherwise nothing. Same approach as Mark various uninitialized arrays with [[indeterminate]] for C++26 simdjson/simdjson#3129.stackvecan empty, hand-written default constructor, sovec()no longer zeroes the limbs.z,zi(long_mul),bigmantandtheor_digitswithFASTFLOAT_INDETERMINATE.The common path is unchanged; it has no such buffers.
Benchmark: 5000 inputs that each sit exactly halfway between two doubles (about 175 digits), Xeon Gold 6338, ns per number:
Tests: the full suite passes with Apple clang (C++11, C++20, and C++26 with ASan/UBSan and
-ftrivial-auto-var-init=pattern) and with GCC 16 (C++20 and C++26, which builds with-Weffc++ -Werror). Compile-time (constexpr) parsing of long, slow-path strings still works in C++20 and C++26.