Skip to content

Comments

fix: add -Wmaybe-uninitialized pragma to union storage constructors#145

Open
alandefreitas wants to merge 1 commit intoboostorg:developfrom
alandefreitas:fix/maybe-uninitialized-pragma
Open

fix: add -Wmaybe-uninitialized pragma to union storage constructors#145
alandefreitas wants to merge 1 commit intoboostorg:developfrom
alandefreitas:fix/maybe-uninitialized-pragma

Conversation

@alandefreitas
Copy link
Member

GCC 7+ at -O3 produces false-positive -Wmaybe-uninitialized warnings when inlining through the constexpr_union_storage_t and fallback_union_storage_t constructors. Same class of false positive as boostorg/variant2#55 — union with a dummy and value member, constructor initializes value.

Adds scoped pragmas around both forwarding constructors in union_optional.hpp.

Refs boostorg/url#981

GCC 7+ produces false-positive -Wmaybe-uninitialized warnings at -O3
when deeply inlining through union constructors that initialize one
member while another (dummy_) exists. This is the same class of false
positive addressed in boostorg/variant2#55.

The pragmas are placed around the forwarding constructors in both
constexpr_union_storage_t and fallback_union_storage_t.
@alandefreitas alandefreitas force-pushed the fix/maybe-uninitialized-pragma branch from f6bcfaa to 88e2378 Compare February 24, 2026 17:11
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