An overflow may happen if there is an overflow for the type (e.g. reading '300' into an unsigned char).
The function returns either a positive number indicating the number of characters successfully read from the string (if it encountered a non-digit character) or a negative number indicating an error code.