Skip to content

Don't zero-initialize stack buffers under C++26 erroneous behavior - #5050

Open
brevzin wants to merge 5 commits into
fmtlib:mainfrom
brevzin:indeterminate
Open

brevzin wants to merge 5 commits into
fmtlib:mainfrom
brevzin:indeterminate

Conversation

@brevzin

@brevzin brevzin commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

C++26 erroneous behavior (like -ftrivial-auto-var-init) makes compilers initialize automatic variables that have no initializer, which gcc 16 does by default in C++26 mode. As a result, every call that uses a local memory_buffer, counting_buffer, or iterator_buffer now unnecessary zeroes that entire buffer before writing to it (along with various other local char arrays).

This PR adds FMT_INDETERMINATE ([[indeterminate]] in C++26, or [[gnu::uninitialized]] or [[clang::uninitialized]] if available) and uses it on local buffers that are always written before they are read.

@brevzin
brevzin requested a review from vitaut as a code owner November 30, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant