/*
  Issue:
    On NetBSD/vax 6 BETA2 strtod() does not check for VAX FP overflow correctly
    and so large numbers trigger a SIGFPE.

  Files:
   - sigfpe_test.c: this file
   - strtod.c: strtod implementation from NetBSD libc for debugging
   - arith.h gd_qnan.h gdtoa.h gdtoaimp.h: (infrastructure files)

cc -Wall -DNO_FENV_H -g -o sigfpe_test sigfpe_test.c strtod.c && ./sigfpe_test

SIGFPPE at strtod.c:522
    dval(&rv) *= bigtens[j];

*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    const char *s= "12345678901234567890123456789012345678901234567890123456";
    char *ep;
    double d;

    d = strtod(s, &ep);
    if (ep == s || errno == ERANGE)
        puts("Not a valid number");
    else
        printf("Valid number: %lf", d);
    return 0;
}
