ID Number: Q41220
5.00 5.10 6.00 6.00a 6.00ax
MS-DOS
Summary:
SYMPTOMS
When compiling a program that uses signal() with an 80287
coprocessor, everything works correctly the first time the program
runs; if run a second time, the computer is halted.
STATUS
This problem has been confirmed with the earlier 80287
coprocessors, and has been corrected in later 80287 chips.
More Information:
The program example in the "Microsoft C Optimizing Compiler: Run-Time
Library Reference" manual for version 5.1, page 280, locks up the
computer the second time the program is executed with an earlier
80287. The following is the example:
Sample Code
-----------
/* Compile options needed: none
*/
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include <float.h>
int fphandler ();
jmp_buf mark;
double a = 1.0, b = 0.0, c;
void main()
{
if( signal(SIGFPE, fphandler) == (int(*) () ) -1 )
abort();
if( setjmp(mark) == 0 )
{
c = a/b;
printf( "Should never get here\n" );
}
printf( "Recovered from floating-point error\n" );
}
int fphandler( sig, num )
int sig, num;
{
printf( "signal = %d subcode = %d\n", sig, num );
_fpreset();
longjmp( mark, -1 );
}
Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax