]> git.sesse.net Git - stockfish/commit
Fix undefined behaviour with unaligned loads in syzygy code
authorJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sat, 5 Nov 2016 08:04:51 +0000 (09:04 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 6 Nov 2016 10:48:07 +0000 (11:48 +0100)
commit876f07cbeea5b583ca75685cefa0fd4be1e904a4
tree61815b418b2e6d9f4a2bfc1c6eab5d6fa80016ce
parentf5d3f0ded6839f2eafd69ed5e561c15506518829
Fix undefined behaviour with unaligned loads in syzygy code

Casting a pointer to a different type with stricter alignment
requirements yields to implementation dependent behaviour.
Practicaly everything is fine for common platforms because the
CPU/OS/compiler will generate correct code, but anyhow it is
better to be safe than sorry.

Testing with dbg_hit_on() shows that the unalignment accesses are
very rare (below 0.1%) so it makes sense to split the code in a
fast path for the common case and a slower path as a fallback.

No functional change (verified with TB enabled).
src/syzygy/tbprobe.cpp