[Bug c/7054] #pragma pack handled incorrectly
jbeulich at novell dot com
gcc-bugzilla@gcc.gnu.org
Thu Nov 20 15:00:00 GMT 2003
------- Additional Comments From jbeulich at novell dot com 2003-11-20 15:00 -------
This depends on the default alignment. With the example given you need a
compiler configured for 8-byte default alignment to see a difference (i.e.
Cygwin's, but not Linux'). When this is the case (which you can check by
compiling with the three pragma-s commented), the expected offset is 16. Then,
when you uncomment the block, the expected offset is still 16, but the offset
found is 12 as you checked.
On Linux, you could slightly change the example:
#pragma pack(push, 8)
#pragma pack(2)
#pragma pack(pop)
struct s {
unsigned u1;
unsigned short us;
unsigned u2;
};
unsigned test(const struct s*ps) {
return ps->u2;
}
where the expected offset with and without pragma-s is 8, but the one found with
pragma-s is 6.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7054
More information about the Gcc-bugs
mailing list