Miron Berlin <mironatpro@hotmail.com> writes:
> Functionstrtoint has a bug. It would not report ERANGE on Windows OS compiled with Microsoft Visual Studio compiler.
Have you actually tested that? AFAICS, the code as given works
perfectly fine on platforms where long is the same width as int.
The lines
if (val != (int) val)
errno = ERANGE;
are dead code then (and possibly will be elided by the compiler),
but it doesn't matter because then strtol can be expected to
set ERANGE properly for values outside the int range.
Possibly it'd be worth adding a comment to point this out.
regards, tom lane