Suppose I have a C program that manifests a floating-point overflow, such as in the example below.
int main(){
double x,y;
x=1e+300;
y=x*x;
printf ("x = %.5g; y = %.5g, MAX = %.5g\n", x, y, DBL_MAX);
}
My goal is to catch the exception at run-time. I have thousands of C programs, so I will need to do it in an automated way. I wonder if there exists a C command line option for my purpose?
What is expected is:
gcc myprog.c --the_option_wanted
==> This command is expected to compile myprog.c without any problem./a.out
==> This command runs myprog.c, and the floating-point exception is expected to become a warning or error when running it.