Article View: gnu.gcc.bug
Article #1280matherr not invoked for sqrt domain errors (GCC 2.3.1, sparc)
From: 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 ----
Technical Details
Message-ID:
<9211060117.AA03028@farside.twinsun.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggertShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!charon.amdahl.com!pacbell.com!decwrl!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert From: eggert@twinsun.COM (Paul Eggert) Subject: matherr not invoked for sqrt domain errors (GCC 2.3.1, sparc) Message-ID: <9211060117.AA03028@farside.twinsun.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 6 Nov 1992 01:17:46 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 59