Live data from Hacker News

Portability woes: Endianness and Alignment, Part 2

fastcompression.blogspot.com

1–3 of 3 posts

Re: Portability woes: Endianness and Alignment, Part 2

#3
post #2

People should read Rob Pike's "The byte order fallacy," which was already discussed here: https://news.ycombinator.com/item?id=3796378 http://commandcenter.blogspot.com/2012/04/byte-order-fallacy...

I have a lot of respect for Rob Pike. Doing what he says guarantees correct operation in typical cases, when the memory is cacheable. If CPU arch doesn't support unaligned loads, the compiler must additionally be able to deduce pointer alignment or it's forced to generate separate loads.

However, if performance is important, doing what Pike says doesn't always make sense. The case discussed in the article in question is one those.