Skip to content

Fix GCC 11 -Wmaybe-uninitialized false positive in document_stream_tests - #2875

Merged
lemire merged 1 commit into
masterfrom
fix-gcc11-maybe-uninitialized
Sep 22, 2026
Merged

lemire merged 1 commit into
masterfrom
fix-gcc11-maybe-uninitialized

Conversation

@lemire

@lemire lemire commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

Master is currently red on Ubuntu 22.04 CI (GCC 11) since #2870 was merged:

tests/dom/../test_macros.h:76:3: error: 'v' may be used uninitialized in this function [-Werror=maybe-uninitialized]
tests/dom/document_stream_tests.cpp:1583:17: note: 'v' was declared here

This is a GCC 11.4 false positive in the Debug (-Og -Werror) developer build: v is only read after doc["i"].get(v) returned SUCCESS, which always writes it. Neither #2870 nor #2872 triggers it on its own; it only shows up with both sets of header changes in the translation unit (they reach document_stream_tests.cpp via simdjson.h), and it goes away with -fno-ipa-pure-const, so it is GCC's IPA analysis flipping on unrelated call-graph changes rather than anything wrong in either PR.

Fix: initialize every int64_t v; local in tests/dom/document_stream_tests.cpp (17 sites). Only line 1583 fails today, but the others are the same pattern and could start failing on the next unrelated header change.

Verified in an amd64 Ubuntu 22.04 container with GCC 11.4.0 using the CI's Debug developer-mode configuration: master fails, this branch builds cleanly and document_stream_tests passes.

…-Wmaybe-uninitialized

GCC 11.4 (Ubuntu 22.04 CI, Debug/-Og developer build with -Werror) reports a
false-positive 'v may be used uninitialized' on the json_sequence subtest
since #2870 landed on top of #2872. The variable is only read after
get(v) returned SUCCESS, so this is purely a diagnostic issue; the warning
flips on unrelated call-graph changes in headers pulled in via simdjson.h.
Initialize all the int64_t v locals in the file so the other identical
sites cannot start failing the same way later.
@lemire
lemire force-pushed the fix-gcc11-maybe-uninitialized branch from 6c85544 to 7cf1861 Compare September 22, 2026 02:23
@lemire
lemire merged commit 4f84e35 into master Sep 22, 2026
215 checks passed
@lemire
lemire deleted the fix-gcc11-maybe-uninitialized branch September 22, 2026 02:24
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