mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
fix ub type punning
This commit is contained in:
parent
7f28a89273
commit
a930ad25e1
@ -161,14 +161,9 @@ template <typename T>
|
||||
requires (sizeof(T) <= sizeof(UInt64))
|
||||
inline size_t DefaultHash64(T key)
|
||||
{
|
||||
union
|
||||
{
|
||||
T in;
|
||||
DB::UInt64 out;
|
||||
} u;
|
||||
u.out = 0;
|
||||
u.in = key;
|
||||
return intHash64(u.out);
|
||||
DB::UInt64 out {0};
|
||||
std::memcpy(&out, &key, sizeof(T));
|
||||
return intHash64(out);
|
||||
}
|
||||
|
||||
|
||||
@ -441,14 +436,9 @@ struct IntHash32
|
||||
}
|
||||
else if constexpr (sizeof(T) <= sizeof(UInt64))
|
||||
{
|
||||
union
|
||||
{
|
||||
T in;
|
||||
DB::UInt64 out;
|
||||
} u;
|
||||
u.out = 0;
|
||||
u.in = key;
|
||||
return intHash32<salt>(u.out);
|
||||
DB::UInt64 out {0};
|
||||
std::memcpy(&out, &key, sizeof(T));
|
||||
return intHash32<salt>(out);
|
||||
}
|
||||
|
||||
UNREACHABLE();
|
||||
|
Loading…
Reference in New Issue
Block a user