mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-10-12 04:17:51 +00:00
add static lifetime to constexpr values to force compile time evaluation where possible
Signed-off-by: arades79 <scravers@protonmail.com>
This commit is contained in:
parent
ba774d82c7
commit
adcef452e0
101 changed files with 309 additions and 303 deletions
|
@ -39,7 +39,7 @@ void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin
|
|||
// which may be overwritten by the result of the addition
|
||||
if (IR::Inst * overflow{inst.GetAssociatedPseudoOperation(IR::Opcode::GetOverflowFromOp)}) {
|
||||
// https://stackoverflow.com/questions/55468823/how-to-detect-integer-overflow-in-c
|
||||
constexpr u32 s32_max{static_cast<u32>(std::numeric_limits<s32>::max())};
|
||||
constexpr static u32 s32_max{static_cast<u32>(std::numeric_limits<s32>::max())};
|
||||
const auto sub_a{fmt::format("{}u-{}", s32_max, a)};
|
||||
const auto positive_result{fmt::format("int({})>int({})", b, sub_a)};
|
||||
const auto negative_result{fmt::format("int({})<int({})", b, sub_a)};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue