Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use may_alias with unaligned reads to fix miscompilation on GCC #1013

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions xxhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
Loading