fix(ec): avoid GCC -O3 -Wfree-nonheap-object false positive in BuildTranscript - #800
Merged
got3nks merged 1 commit intoAug 5, 2026
Merged
Conversation
…ranscript reserve() followed by repeated push_back()/insert() on the same vector tricks GCC 15's inlined growth-guard analysis into losing track of the allocation's provenance, even though capacity is never exceeded. Size the vector once and fill it by copy instead: same output, one allocation, and the warning-triggering code pattern is gone.
mrjimenez
force-pushed
the
fix/eccrypt-wfree-nonheap-warning
branch
from
August 5, 2026 00:25
6d08453 to
b37af13
Compare
|
Merged — thanks @mrjimenez. Verified byte-identical across 200k inputs including both sides of the 255-cipher cap, so the transcript format is unchanged.
|
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.
Summary
-O3) emits a-Wfree-nonheap-objectwarning twice forECCrypt::BuildTranscript()(once per translation unit it's compiled in).reserve()followed by repeatedpush_back()/insert()on the same vector — GCC inlines the vector's growth-guard cleanup and loses track of the allocation's provenance, even though capacity is never actually exceeded. Removingreserve()alone also silences it, confirming this is a compiler analysis artifact, not a real bug.std::copy/std::copy_n) instead ofreserve()+ growth calls. Single allocation, byte-for-byte identical output, and the pattern that confuses the analyzer is gone rather than merely avoided by luck.Test plan
cmake --build build --clean-first) — zero compiler warningsctest— all 33 unit tests pass, includingECCryptTest