Skip to content

Fix GCC SmallVector growth uninitialized warning - #53

Merged
cyyever merged 1 commit into
trimfrom
fix/smallvector-gcc-uninitialized
Nov 17, 2026
Merged

cyyever merged 1 commit into
trimfrom
fix/smallvector-gcc-uninitialized

Conversation

@cyyever

@cyyever cyyever commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator

Linked issue or supporting maintainer

Requested by the BakeLab maintainer to repair the Gitea CUDA wheel build.

BC-breaking?

No.

Agent details (AI-generated)

Gitea CUDA wheel run 8608 fails under GCC 16 at SmallVector.h:150: constructing or resizing an empty SmallVector passes the address of uninitialized inline storage to the out-of-line grow_pod helper. GCC assumes its const pointer parameter may read that storage.

Annotate the address-only FirstEl parameter with GCC's access(none, 2) (parameter 1 is the implicit this). The implementation only compares FirstEl with BeginX; live elements are copied through BeginX using the initialized size. This preserves the ABI and allocation behavior, avoids zeroing unused inline capacity, and keeps -Werror=maybe-uninitialized enabled. Clang and older GCC builds do not receive the attribute.

Validation: a standalone reproducer using this header for both sized construction and resize fails before the fix with GCC 16 -O3 -Werror=maybe-uninitialized and compiles after it. The same reproducer compiles with Clang and -Werror. git diff --check passes. Full CUDA compilation and lintrunner were not run locally (lintrunner unavailable); remote CD must validate the full build.

@cyyever
cyyever marked this pull request as ready for review November 17, 2026 03:53
@cyyever
cyyever merged commit 19ae2c6 into trim Nov 17, 2026
55 checks passed
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