From 2d94529192c75236f8b3c959d1aa082b0dc9e0ce Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 18 Jun 2025 16:25:35 -0700 Subject: [PATCH] added test_alias expected to fail due to #1013 --- .github/workflows/ci.yml | 11 ++++++----- .gitignore | 1 + tests/Makefile | 6 +++++- tests/test_alias.c | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 tests/test_alias.c diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82dfff1..be746ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,15 +37,11 @@ # elapsed time. # # Todos: -# - [ ] Linux: Add native ARM runner. # - [ ] Linux: Add native ARM64 runner. # - [ ] Linux: Add native PPC64LE runner. # - [ ] Linux: Add native S390X runner. -# - [ ] Windows: Add VS2013. -# - [ ] Windows: Add VS2015. # - [ ] Windows: Add clang for msys2. -# - [ ] Windows: Add native or emulated ARM runner. -# - [ ] Windows: Add native or emulated ARM64 runner. +# - [ ] Windows: Add native or emulated ARM64 runner (note: currently unreliable) # Name of the workflow is also displayed as a SVG badge @@ -167,6 +163,11 @@ jobs: run: | make clean test-all + - name: test-alias + run: | + make clean + make -C tests test_alias + ubuntu-consistency: name: Linux x64 check results consistency diff --git a/.gitignore b/.gitignore index 764a311..d0661ef 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ dispatch tests/generate_unicode_test tests/sanity_test tests/sanity_test_vectors_generator +tests/test_alias fuzzer # Mac OS-X artefacts diff --git a/tests/Makefile b/tests/Makefile index d91a990..f1f60ae 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -50,7 +50,7 @@ C_SRCDIRS = . .. ../cli include ../build/make/multiconf.make .PHONY: all -all: test +all: test test_alias .PHONY: test test: test_multiInclude test_unicode test_sanity @@ -127,6 +127,10 @@ sanity_test_vectors.h: sanity_test_vectors_generator multiInclude_withxxhash: $(eval $(call c_program,multiInclude_withxxhash,multiInclude.o xxhash.o)) +test_alias: CPPFLAGS += -I.. +test_alias: CFLAGS += -O3 -Werror +$(eval $(call c_program,test_alias,test_alias.o)) + .PHONY: clean clean: @$(RM) *.o diff --git a/tests/test_alias.c b/tests/test_alias.c new file mode 100644 index 0000000..af1065f --- /dev/null +++ b/tests/test_alias.c @@ -0,0 +1,18 @@ +#define XXH_INLINE_ALL + +#include +#include +#include "xxhash.h" + +int main() { + // it seems this has to be exactly 24 bytes. + union { + char x[24]; + // force 8-byte alignment without making + // aliasable with uint64_t. + void *y[3]; + } data = {.x = "garblegarblegarblegarble"}; + uint64_t hash = XXH64(&data, sizeof(data), 0); + printf("%016"PRIx64"\n", hash); + return 0; +}