https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109039
Bug ID: 109039 Summary: Miscompilation with no_unique_address and bitfields Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: coillol at yandex dot ru Target Milestone: --- g++ miscompiles the following code starting from version 12.1 (-std=c++20, any optimization mode). ``` #include <cassert> struct X { short x0 : 7; short x1 : 8; X() { init(); assert(get() == 3); } void init() { x0 = 1; x1 = 2; } int get() { return x0 + x1; } }; struct S { [[no_unique_address]] X x; char c = 0; }; int main() { S s; assert(s.x.get() == 3); return 0; } ``` Program hits assertion in main when executed. Links to godbolt: https://godbolt.org/z/xG186673P (12.1), https://godbolt.org/z/MaP56rfhe (trunk).