Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Paul Eggert
Fri, 06 Nov 1992 01:17
matherr not invoked for sqrt domain errors (GCC 2.3.1, sparc)
Author: Paul Eggert
Date: Fri, 06 Nov 1992 01:17
Date: Fri, 06 Nov 1992 01:17
58 lines
2294 bytes
2294 bytes
The GCC manual says that TARGET_EDOM should not be defined if mathematical
functions on your system use `matherr' when there is an error. The
mathematical functions in SunOS 4.1.2 (sparc) use `matherr', but
config/sparc.h defines TARGET_EDOM. The following scenario illustrates the
discrepancy that this causes.
$ cat t.c
#include <math.h>
int matherr (e) struct exception *e; {
printf("matherr invoked from %s\n", e->name);
return 1;
}
main() {
printf("sqrt(-1) == %g\n", sqrt(-1.0));
return 0;
}
$ cc -O t.c -lm
$ ./a.out
matherr invoked from sqrt
sqrt(-1) == NaN
$ gcc -O t.c -lm
$ ./a.out
sqrt(-1) == NaN
The two outputs should be identical, but GCC's a.out doesn't invoke matherr so
the message is not printed.
Here is a patch.
Fri Nov 6 00:41:53 1992 Paul Eggert (eggert@twinsun.com)
* sparc.h (TARGET_EDOM, GEN_ERRNO_RTX): Removed, since Sun's
math library invokes matherr.
===================================================================
RCS file: config/sparc.h,v
retrieving revision 2.3
retrieving revision 2.3.1.1
diff -c -r2.3 -r2.3.1.1
*** config/sparc.h 1992/10/20 21:12:29 2.3
--- config/sparc.h 1992/11/06 00:41:53 2.3.1.1
***************
*** 1277,1290 ****
in one reasonably fast instruction. */
#define MOVE_MAX 8
- /* This is the value of the error code EDOM for this machine,
- used by the sqrt instruction. */
- #define TARGET_EDOM 33
-
- /* This is how to refer to the variable errno. */
- #define GEN_ERRNO_RTX \
- gen_rtx (MEM, SImode, gen_rtx (SYMBOL_REF, Pmode, "errno"))
-
/* Define if normal loads of shorter-than-word items from memory clears
the rest of the bigs in the register. */
#define BYTE_LOADS_ZERO_EXTEND
--- 1277,1282 ----
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads