Misc: fixed strict aliasing violation in ImHashData() affecting Clang 23 + SSE 4.2 + -flto. (#9557, #9560)

This commit is contained in:
Stanislaw Halik 2026-09-26 12:34:24 +02:00 • committed by ocornut
parent 09f7a0f062
commit db436a15bc
2 changed files with 9 additions and 0 deletions

View file

@ -114,6 +114,9 @@ Other Changes:
trivial functions when stepping into.
- Tagged various trivial functions using `IM_NODEBUGSTEP`: `ImVec2()`, `ImVec4()` etc.
and various operators.
- Fixed strict aliasing violation in `ImHashData()` affecting Clang 23 + SSE 4.2 + -flto.
Could manifest as `ImFontAtlasBakedGetId()` computation omitting font size from
the hashed data. (#9557, #9560) [@sthalik]
- IO: restore default clipboard/ime/shell platform handlers on ClearPlatformHandlers(), fixing
issues switching backends mid-session to one relying on default. (#9537, #8945, #2769) [@lstalmir]
- DrawList:

View file

@ -2493,7 +2493,13 @@ ImGuiID ImHashData(const void* data_p, size_t data_size, ImGuiID seed)
#else
while (data + 4 <= data_end)
{
#if defined(_DEBUG) || defined(_MSC_VER)
crc = _mm_crc32_u32(crc, *(ImU32*)data);
#else
ImU32 v;
memcpy(&v, data, sizeof(ImU32)); // Avoid aliasing violation (#9557)
crc = _mm_crc32_u32(crc, v);
#endif
data += 4;
}
while (data < data_end)