diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt --- a/libc/src/__support/CMakeLists.txt +++ b/libc/src/__support/CMakeLists.txt @@ -72,6 +72,7 @@ .str_to_num_result libc.src.errno.errno libc.src.__support.CPP.limits + libc.src.__support.CPP.type_traits libc.src.__support.common ) diff --git a/libc/src/__support/str_to_integer.h b/libc/src/__support/str_to_integer.h --- a/libc/src/__support/str_to_integer.h +++ b/libc/src/__support/str_to_integer.h @@ -10,6 +10,7 @@ #define LIBC_SRC_SUPPORT_STR_TO_INTEGER_H #include "src/__support/CPP/limits.h" +#include "src/__support/CPP/type_traits.h" #include "src/__support/common.h" #include "src/__support/ctype_utils.h" #include "src/__support/str_to_num_result.h" @@ -142,7 +143,9 @@ return {cpp::numeric_limits::min(), str_len, error_val}; } - return {is_positive ? static_cast(result) : -static_cast(result), + return {is_positive + ? static_cast(result) + : static_cast(-static_cast>(result)), str_len, error_val}; }