[Bug c++/118002] New: Padding bits still not cleared in empty classes
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Dec 11 15:46:32 GMT 2024
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.
More information about the Gcc-bugs
mailing list