mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 09:47:46 +00:00
Fix undefined behavior
From cppreference: "It is undefined behavior to read from the member of the union that wasn't most recently written. Many compilers implement, as a non-standard language extension, the ability to read inactive members of a union." closes https://github.com/official-stockfish/Stockfish/pull/5811 no functional change
This commit is contained in:
committed by
Joost VandeVondele
parent
aa894c0f93
commit
d606311e55
+2
-5
@@ -120,11 +120,8 @@ void sync_cout_start();
|
||||
void sync_cout_end();
|
||||
|
||||
// True if and only if the binary is compiled on a little-endian machine
|
||||
static inline const union {
|
||||
uint32_t i;
|
||||
char c[4];
|
||||
} Le = {0x01020304};
|
||||
static inline const bool IsLittleEndian = (Le.c[0] == 4);
|
||||
static inline const std::uint16_t Le = 1;
|
||||
static inline const bool IsLittleEndian = *reinterpret_cast<const char*>(&Le) == 1;
|
||||
|
||||
|
||||
template<typename T, std::size_t MaxSize>
|
||||
|
||||
Reference in New Issue
Block a user