mirror of
https://github.com/Cyan4973/xxHash.git
synced 2026-01-19 04:52:10 +00:00
Merge pull request #1013 from lassipulkkinen/unaligned_read_may_alias
Use may_alias with unaligned reads to fix miscompilation on GCC
This commit is contained in:
4
xxhash.h
4
xxhash.h
@@ -2661,7 +2661,7 @@ typedef union { xxh_u32 u32; } __attribute__((__packed__)) unalign;
|
||||
#endif
|
||||
static xxh_u32 XXH_read32(const void* ptr)
|
||||
{
|
||||
typedef __attribute__((__aligned__(1))) xxh_u32 xxh_unalign32;
|
||||
typedef __attribute__((__aligned__(1))) __attribute__((__may_alias__)) xxh_u32 xxh_unalign32;
|
||||
return *((const xxh_unalign32*)ptr);
|
||||
}
|
||||
|
||||
@@ -3374,7 +3374,7 @@ typedef union { xxh_u32 u32; xxh_u64 u64; } __attribute__((__packed__)) unalign6
|
||||
#endif
|
||||
static xxh_u64 XXH_read64(const void* ptr)
|
||||
{
|
||||
typedef __attribute__((__aligned__(1))) xxh_u64 xxh_unalign64;
|
||||
typedef __attribute__((__aligned__(1))) __attribute__((__may_alias__)) xxh_u64 xxh_unalign64;
|
||||
return *((const xxh_unalign64*)ptr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user