www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/01/14/10:57:46

Date: Thu, 14 Jan 1993 10:13 EST
From: AE2Y AT VAX5 DOT CIT DOT CORNELL DOT EDU
Subject: Trapping floating point exceptions
To: djgpp AT sun DOT soe DOT clarkson DOT edu

The following program is compiled with

gcc fptest.c -Wall -lm -m486 -O

and runs without printing any message about its two floating point
execptions:

/* this is a floating point test */
#include <math.h>
int main(void)
{
double
   w,
   x,
   y = 1.0,
   z = 0.0,
   t = -1.0;

   w = y/z ;
   x = log(t) ;
   return 0 ;
}


I would like to know how to:

1) trap the exceptions and stop the program as soon as one occurs,
   à la FORTRAN;

2) if possible at all, print the function and the line in which
   the exception occurred.

Any suggestions will be appreciated.

Nelson Luis Dias
ae2y AT vax5 DOT cit DOT cornell DOT edu

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019