https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118107
Bug ID: 118107 Summary: false warning: "${inactive union member} may be used uninitialized" (in constructor call activating another, empty struct member, as union member) Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: giel+gcc at mortis dot eu Target Milestone: --- Created attachment 59909 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59909&action=edit reproduction scenario Attached I have a completely cut down example that triggers a false positive warning "X may be uninitialized". Also the same on compiler explorer: https://godbolt.org/z/ErWaT5KMq It only happens with -O1 *and* -fsanitize=undefined (but *not* -fsanitize=undefined,address) (and -Wall -Wextra of course). When increasing code size it needs -O2 at least to trigger. The warning triggers on a call to the default constructor. Which activates an *empty struct* as a union member. But the warning complains about the *inactive* (non-empty) union member (maybe) being used uninitialized.