Nathan Sidwell wrote: > Mark Mitchell wrote: > >> 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. > > > It can be made to work by not packing Baz::m, and that is what g++ does > (with a warning%).
Ah! That makes sense. > % ah, I think that warning should only be given on non-default-packed > arches. Is this your problem Jan? I think the warning should be given only if the base class does not itself have the minimum alignment for the artchitecture. (So that you would get the warning on a system that was packed by default if you used a base class which was explicitly aligned on a wider boundary.) -- Mark Mitchell CodeSourcery, LLC [EMAIL PROTECTED] (916) 791-8304