Re:A bug story: data alignment in C on x86 (2016)
by dmitrygr on Tuesday September 04, 2018 @03:08PM
(#17911875)
Why the surprise? x86 ABI says that a uint32 shall be 32-bit aligned. The fact that CPU can cope with others does not mean ABI allows it. Compiler complies with ABI and assumes your uint32* is 32-bit aligned.
[ Parent
| on HN ]
Re:A bug story: data alignment in C on x86 (2016)
by crististm on Wednesday September 05, 2018 @12:03AM
(#17914951)
I assume because ABI is just a convention for application interoperability. Hardware interface was the problem here.
You can ignore ABI if you are standalone. But you can't ignore the CPU.
Re:A bug story: data alignment in C on x86 (2016)
by dmitrygr on Wednesday September 05, 2018 @01:40PM
(#17920247)
Compiler sees "function" and understands "ABI says that pointer is 32-bit aligned, I can count on that because whoever calls it will also be ABI compatible and make it so"