Re:Open Source at Google: Introducing CityHash
by haberman on Monday April 11, 2011 @08:27PM
(#2435147)
> Any function that uses both of these violates strict aliasing rules
More specifically, any function that uses both of these to access the same data violates strict aliasing rules. But this would imply that the data is being loaded redundantly, which seems unlikely in an implementation where speed is a top priority.
For example, I do not believe the following function violates strict aliasing rules:
void foo(char *p) {
bar(UNALIAGNED_LOAD64(p), UNALIGNED_LOAD32(p+8));
}
ffmpeg has a header of macros to avoid this problem. They have names like AV_RN32A (aligned, native-endian 32-bit read), AV_RL32 (unaligned, little-endian 32-bit read) and so forth.