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

            Bug ID: 118002
           Summary: Padding bits still not cleared in empty classes
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

I think
struct S {};
struct T { S a, b, c, d, e, f, g, h; };
struct U { T i, j, k, l, m, n, o, p; };

[[gnu::noipa]] void
foo (struct U *)
{
}

[[gnu::noipa]] void
bar ()
{
  U u[4];
  __builtin_memset (&u, -1, sizeof (U) * 4);
  foo (&u[0]);
}

[[gnu::noipa]] void
baz ()
{
  U u = U ();
  foo (&u);
  for (int i = 0; i < sizeof (U); ++i)
    if (((char *) &u)[i] != 0)
      __builtin_abort ();
}

int
main ()
{
  bar ();
  baz ();
}

is valid and should pass, but it doesn't because we optimize away all stores to
empty classes.
I think we need to make an exception for CONSTRUCTOR_ZERO_PADDING_BITS rhs.

Reply via email to