Subject: Divide by zero fails to produce SIGFPE
From: [email-masked] (Tijs Michels)

6 Apr 1998 18:23:30 -0700
Message-ID: <[email-masked]>
Reply-To: [email-masked]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7BIT
To: [email-masked]
Cc: [email-masked]

Is it possible to get cygwin32 to respond to
division by zero with SIGFPE?

I ported Yorick 1.4, ran the self test and got the
following error message:

  "**WARNING** 1.0/0.0 does not trigger SIGFPE"

In fact, division by zero yields "Inf".
For Yorick to run reliably, division by zero
*must* yield SIGFPE.

Quite a few systems fail to produce SIGFPE, and
the Yorick distribution comes with a patch for
most of them. Unfortunately cygwin32 is not included.
Now I searched the cygwin32 tree for "divide by zero"
and found in +++/i386-cygwin32/include/ieeefp.h:

  [...]
  /* EXCEPTIONS */
  typedef int fp_except;
  #define FP_X_INV 0x10	/* Invalid operation   */
  #define FP_X_DX  0x80	/* Divide by zero      */
  #define FP_X_OFL 0x04	/* Overflow exception  */
  #define FP_X_UFL 0x02	/* Underflow exception */
  #define FP_X_IMP 0x01	/* imprecise exception */
  [...]

Yorick has a patch for Solaris which reads:

  #include < ieeefp.h >
    fpsetmask(FP_X_INV | FP_X_DZ | FP_X_OFL);

However, cygwin32 does not seem to include the
fpsetmask function. (And what about the difference
between FP_X_DX and FP_X_DZ? Is this a typo?)

I contacted David Munro ([email-masked]), author
of Yorick. He was interested in the cygwin32 port,
but unaware of a way to get cygwin32 to produce
SIGFPE. However, he did send me a program to test
for proper divide by zero handling. It is attached
to this mail. I can't get it to produce SIGFPE.
Perhaps someone better versed in C than I could give
it a shot.

Thanks and best wishes,

Tijs
[email-masked]

Ps: Apart from this, Yorick works great!
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".