This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC and UltraSparc 2


>> Sorry if I am insistent, but I've tried with "-fpack-struct".
>> This cause the structs to be packed, as expected, but when I access to a
>> disaligned field of a struct with a pointer, a BUS ERROR is raised:

>Hum.  I thought this option was supposed to be the same as
>__attribute__((packed)) which would imply misalignment.

This won't work with __attribute__((packed)) either.  In order for this to
work, the pointer has to be declared as a pointer to unaligned data.
Unfortunately, we have no syntax for that, so there is no way to do this
with current gcc.  This would be a useful extension to have though, as it
would make it easier to manipulate packed structures and other unaligned
data.

Meanwhile, if you want to use packed structures, you have to refer to the
unaligned fields directly through the packed structure.  You can not take the
address of a unaligned field and later dereference the pointer.  That will give
you an unaligned access.  You can take the address of a field and then pass
it through memcpy/strcpy to access the unaligned field.

Jim


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]