My strtol function fails to set errno during overflown conversion.
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <getopt.h>
#include <errno.h>
#include <stdlib.h>
int main(int argc, char **argv) {
errno = 0;
int e = strtol("1000000000000000", NULL, 10);
printf("%d %d\n", errno, e);
return 0;
}
returns
0 -1530494976
What do I do wrong?
Compiler
gcc (Ubuntu 4.9.2-10ubuntu13) 4.9.2
Options
gcc -Wall -std=gnu99 -O2