mirror of
https://github.com/official-stockfish/Stockfish.git
synced 2026-07-23 13:17:12 +00:00
Fix undefined behavior
C++ standard does not define `uint8_t` as an allowed pointer alias type. Despite `uint8_t` being `unsigned char` on most platforms, this is not enforced by the standard. https://eel.is/c++draft/basic.lval#11 https://stackoverflow.com/a/16138470 closes https://github.com/official-stockfish/Stockfish/pull/6420 No functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
4b71d8e202
commit
1d504b927f
@@ -77,10 +77,9 @@ struct AccumulatorCaches {
|
||||
// To initialize a refresh entry, we set all its bitboards empty,
|
||||
// so we put the biases in the accumulation, without any weights on top
|
||||
void clear(const std::array<BiasType, Size>& biases) {
|
||||
|
||||
accumulation = biases;
|
||||
std::memset((uint8_t*) this + offsetof(Entry, psqtAccumulation), 0,
|
||||
sizeof(Entry) - offsetof(Entry, psqtAccumulation));
|
||||
std::memset(reinterpret_cast<std::byte*>(this) + offsetof(Entry, psqtAccumulation),
|
||||
0, sizeof(Entry) - offsetof(Entry, psqtAccumulation));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user