From 0e437c41e5903cf14b739bb3358b5a6dddc34158 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 20 Jun 2018 16:38:28 -0400 Subject: [PATCH] ActionReplay: Use Common::BitCast instead of reinterpret_cast in Subtype_AddCode() Using reinterpret_cast (or a C-styled equivalent) to reinterpret integers as floating-point values and vice-versa invokes undefined behavior. Instead, use BitCast, which does this in a well-defined manner. --- Source/Core/Core/ActionReplay.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/ActionReplay.cpp b/Source/Core/Core/ActionReplay.cpp index 02e70cc5cc..15ab75fffe 100644 --- a/Source/Core/Core/ActionReplay.cpp +++ b/Source/Core/Core/ActionReplay.cpp @@ -31,6 +31,7 @@ #include #include +#include "Common/BitUtils.h" #include "Common/CommonTypes.h" #include "Common/IniFile.h" #include "Common/Logging/Log.h" @@ -474,10 +475,10 @@ static bool Subtype_AddCode(const ARAddr& addr, const u32 data) LogInfo("--------"); const u32 read = PowerPC::HostRead_U32(new_addr); - const float read_float = reinterpret_cast(read); + const float read_float = Common::BitCast(read); // data contains an (unsigned?) integer value const float fread = read_float + static_cast(data); - const u32 newval = reinterpret_cast(fread); + const u32 newval = Common::BitCast(fread); PowerPC::HostWrite_U32(newval, new_addr); LogInfo("Old Value %08x", read); LogInfo("Increment %08x", data);