mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
Fix: OverflowSafeInt negation not handling INT64_MIN
INT64_MIN negated is above INT64_MAX, and would overflow. Instead, when negating INT64_MIN make it INT64_MAX. This does mean that -(-(INT64_MIN)) != INT64_MIN.
This commit is contained in:
parent
9b0bb21f3b
commit
1e439979f7
@ -34,7 +34,7 @@ public:
|
||||
|
||||
inline OverflowSafeInt& operator = (const OverflowSafeInt& other) { this->m_value = other.m_value; return *this; }
|
||||
|
||||
inline OverflowSafeInt operator - () const { return OverflowSafeInt(-this->m_value); }
|
||||
inline OverflowSafeInt operator - () const { return OverflowSafeInt(this->m_value == T_MIN ? T_MAX : -this->m_value); }
|
||||
|
||||
/**
|
||||
* Safe implementation of addition.
|
||||
|
Loading…
Reference in New Issue
Block a user