In 7.22.1.7 p. 8 the standard stipulates:
"If the correct value is outside the range of representable values, LONG_MIN, LONG_MAX, LLONG_MIN, LLONG_MAX, ULONG_MAX, or ULLONG_MAX is returned (according to the return type and sign of the value, if any), and the value of the macro ERANGE is stored in errno."
In the following example Pelles C returns "errno == 0" although the passed string provides a negative value which is "outside the range of representable values" in an unsigned long long int variable.
Am I mistaken?
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
const char* p_minus_one = "-1";
unsigned long long int result;
errno = 0;
printf("errno before \"strtoull\": %i\n", errno);
result = strtoull(p_minus_one, NULL, 0);
printf("result : %llu\n", result); // expected by ISO/IEC 9899: ok
printf("errno after \"strtoull\" : %i\n", errno); // expected ERANGE = 34 but received 0: bug?
}