[libc-commits] [PATCH] D107792: [libc] add strtoll function and backend
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Aug 10 11:57:49 PDT 2021
sivachandra accepted this revision.
sivachandra added a comment.
This revision is now accepted and ready to land.
In D107792#2937738 <https://reviews.llvm.org/D107792#2937738>, @michaelrj wrote:
> The relevant line from the specification is "The functions atof, atoi, atol, and atoll need not affect the value of the integer expression errno on an error. If the value of the result cannot be represented, the behavior is undefined." From what I can tell that means that we aren't required to set the errno at any time, since if you pass it an out of range number then that is undefined behavior. However, implementations in other libcs do set `errno` to `ERANGE` when `atoi` is passed a number that is greater than 2^63.
> Since this follows the specification, matches expected behavior from other libcs, and simplifies implementation, I think this is the best way forward.
Ah! Not the first time cppreference.com is incomplete: https://en.cppreference.com/w/c/string/byte/atoi
Also, not all libcs set errno in atoi and friends. For example: https://git.musl-libc.org/cgit/musl/tree/src/stdlib/atoi.c.
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
More information about the libc-commits