In message: <20061112192810.GC1173_at_rambler-co.ru> Ruslan Ermilov <ru_at_freebsd.org> writes: : On the other hand, having GCC align "struct foo { char x[11]; }" : on a four-byte boundary (other than for backward compatibility) : doesn't make too much sense to me. It makes a lot of sense, actually, even on i386, which is why the standard allows the compiler a lot of leeway to pad and align such structure. For example, consider this structure assignment: struct foo a,b; a = b; The structure copy here is a LOT faster if the structures are always suitably aligned and padded. If the compiler pads your sample struct to 12 bytes and 4-aligns, the structure copy here can be done with 3 aligned 32-bit moves. Even on i386, aligned operations are a lot faster than unaligned ones. The code mentioned in the original post is simply broken; it does not comply with the ISO C Standard. Tim KientzleReceived on Mon Nov 13 2006 - 01:10:47 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:02 UTC