summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_basic_gcc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/fx_basic_gcc.cpp')
-rw-r--r--core/fxcrt/fx_basic_gcc.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/fxcrt/fx_basic_gcc.cpp b/core/fxcrt/fx_basic_gcc.cpp
index 1b2f01ec89..c3afe1115b 100644
--- a/core/fxcrt/fx_basic_gcc.cpp
+++ b/core/fxcrt/fx_basic_gcc.cpp
@@ -39,7 +39,10 @@ IntType FXSYS_StrToInt(const CharType* str) {
num = num * 10 + val;
str++;
}
- return neg ? -num : num;
+ // When it is a negative value, -num should be returned. Since num may be of
+ // unsigned type, use ~num + 1 to avoid the warning of applying unary minus
+ // operator to unsigned type.
+ return neg ? ~num + 1 : num;
}
template <typename T, typename UT, typename STR_T>