[Ecls-list] Question about FPE underflow andPRINT.SHORT-FLOAT.RANDOM test
Goffioul Michael
goffioul at imec.be
Tue Oct 25 07:41:48 UTC 2005
> On Tue, 2005-10-25 at 15:36 +0200, Goffioul Michael wrote:
> > While running the ANSI tests suite, I noticed that the
> PRINT.SHORT-FLOAT.RANDOM
> > test failed. When anaylizing this, it appears that the code
> execute something
> > like (random least-positive-short-float), which can only
> produce a FPE_UNDERFLOW
> > as the generated float will be smaller than
> least-positive-short-float and assigned
> > to a short-float object. However, the test code only
> expects ARITHMETIC-ERROR.
>
> floating-point-underflow/overflow are subclasses of
> arithmetic-error. If
> they are not properly trapped, then there is something wrong going on
> there. Perhaps the underflow occurs somewhere else, like in the C
> library routines that print the small number? It might be the
> case that
> we have to also must save/clear the FP flags in write_double.
Aaah, OK, so the problem is something else. As stated in the MSDN documentation,
the exception is actually thrown on the next FP unit access, it is not thrown
immediately. In this case, I think what happens is that the (random...) call
actually produces an FE_UNDERFLOW exception, but it is not thrown at that moment.
It is only thrown on next FP unit access, when trying to print it, where the
error is not caught.
Ugh! How to solve this....? MSDN says that the developer should introduce a
FWAIT MASM instruction to force the exception to be thrown, but does this mean
after any FP operation?
Michael.
More information about the ecl-devel
mailing list