The functions of the ato.. group were [semi-] officially "abandoned" by the C language standard back in 1995 (see http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf ) . They do not provide any means for handling error situations. In the standard library C, the functions of the strto... group have replaced them, which provide such tools.
These functions were not officially declared obsolescent due to their widespread occurrence in the old code. They can also potentially be implemented more efficiently than the functions of the strto... group strto... However, real implementations are not usually involved in this, but simply delegate calls to ato... to strto... while ignoring potential errors.
Therefore, if for some reason you insist on using C functions to solve such problems, forget about the existence of functions of the ato... group ato... these are "dead" functions. Use the functions of the group strto...
Of course, given that your question is tagged with the [C ++] tag, you better just use the same tools of the standard C ++ library.
<errno.h>, zeroerrnobeforeatoll()and checkerrno == ERANGEafter. - avpato...group generate undefined behavior when overflowing. They do not exposeerrno. - AnTg++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0. Obviously it is implemented through the usual strtoll, which exposes errno - avpatolimplemented there in your implementation is not interesting to anyone. Behavior is not defined. And your "checks" are no more than an attempt to look at the details of this indefinite behavior. Why do this is not clear. - AnTatoistandard library, it is implemented through a direct caste of the result ofstrtolto theinttype without any checks for exceeding the range. That is no goal to determine the behavior ofato...when the library overflowed before itself, the developers of the library did not set. Implementingato...viastrto...is nothing more than a reasonable saving of code within the framework of the freedom provided by the same indefinite behavior. Do not try to look inside the implementations of standard functions and invent non-existent guarantees based on what you see there. - AnT