[libc-commits] [PATCH] D147258: [libc] Fix UBSan error after D147171
Alex Brachet via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri Mar 31 08:19:14 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9884eb149e61: [libc] Fix UBSan error after D147171 (authored by abrachet).
Herald added a project: libc-project.
Herald added a subscriber: libc-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147258/new/
https://reviews.llvm.org/D147258
Files:
libc/src/__support/CMakeLists.txt
libc/src/__support/str_to_integer.h
Index: libc/src/__support/str_to_integer.h
===================================================================
--- libc/src/__support/str_to_integer.h
+++ 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<T>::min(), str_len, error_val};
}
- return {is_positive ? static_cast<T>(result) : -static_cast<T>(result),
+ return {is_positive
+ ? static_cast<T>(result)
+ : static_cast<T>(-static_cast<cpp::make_unsigned_t<T>>(result)),
str_len, error_val};
}
Index: libc/src/__support/CMakeLists.txt
===================================================================
--- libc/src/__support/CMakeLists.txt
+++ 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
)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147258.510045.patch
Type: text/x-patch
Size: 1171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230331/621c4995/attachment.bin>
More information about the libc-commits
mailing list