[libc-commits] [PATCH] D107999: [libc] Add strtol, strtoul, and strtoull

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Aug 17 11:46:18 PDT 2021


sivachandra accepted this revision.
sivachandra added inline comments.


================
Comment at: libc/src/__support/str_conv_utils.h:127
+
+  return (is_positive) ? static_cast<T>(result) : -static_cast<T>(result);
 }
----------------
You don't need parenthesis around `is_positive`.


================
Comment at: libc/src/__support/str_conv_utils.h:94
+    ++src;
+
+    if (result == ABS_MAX)
----------------
michaelrj wrote:
> sivachandra wrote:
> > Add a comment here explaining the early return; point out that we read out the full number even if it is out of range.
> I did that, in addition I added setting errno, since it's possible to hit ABS_MAX exactly, and then have more numbers. With the code as it was previously that would not set ERANGE in that case. I've added a test to `strtoll_test.cpp` to handle that.
Good catch! You can probably move setting of `errno` from here (and below) to inside the conditional at line 120.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107999/new/

https://reviews.llvm.org/D107999



More information about the libc-commits mailing list