public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109039] New: Miscompilation with no_unique_address and bitfields
@ 2023-03-06 10:46 coillol at yandex dot ru
  2023-03-06 14:44 ` [Bug c++/109039] [12/13 Regression] " ppalka at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: coillol at yandex dot ru @ 2023-03-06 10:46 UTC (permalink / raw)
  To: gcc-bugs

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).

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-03-20 10:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-06 10:46 [Bug c++/109039] New: Miscompilation with no_unique_address and bitfields coillol at yandex dot ru
2023-03-06 14:44 ` [Bug c++/109039] [12/13 Regression] " ppalka at gcc dot gnu.org
2023-03-06 14:59 ` jakub at gcc dot gnu.org
2023-03-09 14:56 ` jakub at gcc dot gnu.org
2023-03-09 16:57 ` jakub at gcc dot gnu.org
2023-03-09 17:12 ` jakub at gcc dot gnu.org
2023-03-10 19:37 ` cvs-commit at gcc dot gnu.org
2023-03-10 19:45 ` [Bug c++/109039] [12 " jakub at gcc dot gnu.org
2023-03-19  5:30 ` cvs-commit at gcc dot gnu.org
2023-03-20 10:29 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).