[comp.lang.pascal] Problem with error trapping with MS PASCAL

VERNERJ%QUCDN.BITNET@wiscvm.wisc.EDU (08/19/87)

Re: a bug at variance with documentation and IEEE standard


        Our Department has been involved in developing
educational software for use on IBM-compatible micro-computers.
To remain abreast of the evolution of the MS-DOS system, we have
recently tried to recompile one of the programs with MS-PASCAL
Version 3.32

        This led to evidence of a bug which is at variance with
documentation for the MS-PASCAL compiler, and more importantly,
with an IEEE standard.  This latter incompatibility is likely to
seriously impact software developed by a variety of users.

        The problem is that the facility for trapping floating
point exceptions malfunctions on machines containing an 8087 or
80287 numeric coprocessor.  For example, the following program
compiled with MS-PASCAL version 3.32 fails to execute the last
two lines properly (in spite of the fact that when compiled with
earlier versions such as 3.2, execution is correct).

program traptest (input,output);
var nan:real8;
      x:real8;

procedure lcwrqq(consts w: word ); extern;

function scwrqq: word; extern;

begin
        lcwrqq(4927); {mask all floating point exceptions}
        writeln(' The stored control word is : ', scwrqq );
        nan:=sqrt( -1 );
        writeln(' The nan is : ', nan );
        x:=0;
        writeln(' sum ( x,nan ) : ', (x+nan) );
        writeln(' sum ( nan,x ) : ', (nan+x))
end.

        While it is possible to circumvent the problem by
disabling the co-processor, the software we are developing
depends on the co-processor for speed -- the program requires
speed for the graphics generated.  We need a fix to the code
that will execute the error trapping as expected while the
computation is done with the co-processor.  Does anyone have
a fix, or a suggestion how we might obtain a fix?

                                        Jim Verner