On 3/5/2012 5:00 AM, Andrew Haley wrote:
On 03/05/2012 09:49 AM, Jonathan Wakely wrote:
On 5 March 2012 06:04, Jeffrey Walton wrote:
Does C/C++ or GCC offer any alignment guarantees?
Alignment requirements are implementation-defined, usually imposed by
the hardware.
Or the system ABI.
C++ and GCC guarantee that data you declare or dynamically allocate
will be correctly aligned, they don't guarantee that playing tricks
with casts will produce correctly aligned data, whether that works
depends on the hardware.
That's not quite right. As long as you follow the rules in the C
and C++ standards, everything will be correctly aligned.
An ambitious statement, which is probably justified for the most popular
64-bit platforms.
I don't think the C and C++ standards help much with AVX-256 alignment.
Maybe I haven't seen enough documentation on how that is dealt with
for the bewildering variety of possibilities. gcc certainly does an
excellent job in a difficult situation.
It's an old story, but I'm glad to be done with 32-bit Windows, where
your statement isn't justified, if it is taken to go beyond minimal
ability to get code working without performance guarantees.
--
Tim Prince