Skip to content

fix(bytes32): use memcpy for std::hash to fix macOS build#190

Merged
hoytech merged 1 commit intohoytech:masterfrom
alienx5499:alienx5499/feat/188-bytes32-hash
Apr 15, 2026
Merged

fix(bytes32): use memcpy for std::hash to fix macOS build#190
hoytech merged 1 commit intohoytech:masterfrom
alienx5499:alienx5499/feat/188-bytes32-hash

Conversation

@alienx5499
Copy link
Copy Markdown
Contributor

This Pull Request fixes/closes #188.

It changes the following:

  • Fix std::hash<Bytes32> in src/Bytes32.h: remove the ill-formed cast from size_t* to uint64_t* (fails on Apple Clang / arm64 where size_t and uint64_t are distinct typedefs).
  • Hash the 32-byte buffer by copying into uint64_t words[4] with memcpy, then XOR the four lanes—same hash shape as before, without pointer type punning.
  • Include <cstdint> so uint64_t is explicit in the header.

Testing

  • make setup-golpe && make -j4 (with dependencies available per README / your environment, e.g. Homebrew CPATH / LIBRARY_PATH on macOS)
  • make src/Decompressor.o (quick check that Bytes32.h compiles on the inclusion path used by the build)

@hoytech
Copy link
Copy Markdown
Owner

hoytech commented Apr 15, 2026

Makes sense, to ensure there's no unaligned access on CPUs where that matters. Probably the compiler can avoid the memcpy when not necessary. Thanks!

@hoytech hoytech merged commit bb8feea into hoytech:master Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bytes32 hash: non-portable cast causes build failure on macOS

2 participants