This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: g++.dg/ext/packed3.C
>>> Nathan Sidwell <nathan@codesourcery.com> 07.12.05 17:22:10 >>>
>Jan Beulich wrote:
>
>> And that is precisely the reason why I think binding a reference to
the
>> whole object or any of its members, when the object itself is a
member
>> of a packed object, is illegal, hence requiring a diagnostic
(unless,
>> like for both other cases, the default is to pack structures).
>
>Doing that will break
> struct Foo { void operator=(Foo const &);};
> struct Baz __attribute__((packed))
> {
> char c;
> Foo m;
> }
>
> void Bar (Baz *ptr)
> {
> ptr->m = something;
> }
>This is something we need to make work.
Why? It's broken. You just cannot embed something that requires
alignment into something that doesn't guarantee alignment, except that
for built-in types, the compiler can synthesize the necessary splitting,
but Foo's assignment operator, in your example, may be totally unaware
that it might get called with an unaligned object.
>>>If your system packs structs by default, you should not be getting
the
>>
>> warning
>>
>>>on any of the uses.
>>
>>
>> But I do, and if I use a native Linux compiler with -fpack-struct,
I
>> also get it (along with a second one on one of the two other
>> instances).
>
>Then I think you have a bug.
Of course I can enter this in bugzilla, but things like that (in my
experience) will likely never get addressed, so it seems a little
pointless...
Jan