[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 12:36:19 PDT 2021
sivachandra added inline comments.
================
Comment at: libc/src/__support/str_conv_utils.h:94
+ ++src;
+
+ if (result == ABS_MAX)
----------------
michaelrj wrote:
> sivachandra wrote:
> > 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.
> Thank you, and we can't do that because that would set `errno` if the input is exactly the maximum as well as if it's greater than the maximum.
Ah, ok!
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