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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
  B b1 (42, -42);
  __builtin_memcpy (buf, &b1, sizeof (b1));
  if (buf[1])
    __builtin_abort ();
  unsigned char m2 alignas (B) [sizeof (B)];
  B *b2 = new (m2) B (1, 2);
  __builtin_memcpy (buf, b2, sizeof (*b2));
  if (buf[1])
    __builtin_abort ();

I think the testcase in the comment 3 patch assumes padding between the members
of struct A, but I don't think that's true for cris-elf where alignof(int) ==
1.

Maybe something like:

struct alignas(4) Int { int i; };
struct A { char c; Int i; };

And then adjust the B constructor to set a.i.i = y

This assumes that changing the definition of A this way wouldn't alter the
behaviour being tested, but I think that's safe.

Reply via email to