https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109039

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And there doesn't even have to be any NSDMI, even
struct X {
  short x0 : 7;
  short x1 : 8;
  X () : x0 (1), x1 (2) {}
  int get () { return x0 + x1; }
};

struct S {
  [[no_unique_address]] X x;
  char c;
  S () : c (0) {}
};

S s;

int
main ()
{
  if (s.x.x0 != 1 || s.x.x1 != 2 || s.c != 0)
    __builtin_abort ();
}
is miscompiled since that revision.  With sizeof (s) == 2 there aren't enough
bytes to
fit the 15 bits of bitfields and another byte.  S::x.x0 is on x86_64 at offset
0, low 7
bits, then S::x.x1 next 8 bits, and S::c is at offset 1, so overlapping the
high 7 bits of S::x.x1.

Reply via email to