struct Foo { void operator=(Foo const &);};
struct Baz __attribute__((packed))
{
char c;
Foo m;
}
void Bar (Baz *ptr)
{
ptr->m = something;
}
I'm not sure it can be made to work, without making the base class
version of Foo::operator= expect unaligned input, which seems an
unreasonable pessimization. I would expect this code to be invalid, and
either issue a diagnostic, or at least be considered undefined behavior.
(In my idea world, ptr->m has type "packed Foo" in this case, and it's
not permissible to binding a "packed Foo" to a "Foo const&", so this
would be invalid, but I could live with undefined.)