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

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Aug 17 12:08:54 PDT 2021

michaelrj added inline comments.

Comment at: libc/src/__support/str_conv_utils.h:94
+    ++src;
+    if (result == ABS_MAX)
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.

  rG LLVM Github Monorepo



More information about the libc-commits mailing list