Subject: bug#12381: Assume C89 or later for math functions.

From: Eli Zaretskii <[email-masked]>
Date: Sat, 08 Sep 2012 18:58:07 +0300

> Date: Sat, 08 Sep 2012 08:31:21 -0700
> From: Paul Eggert <[email-masked]>
> CC: [email-masked]
> 
> The IEEE model is different.  It provides exceptional values for
> overflow and the like, instead of traps or signals.  This is true even
> for floating point exceptions in library functions.  There is a
> run-time option that causes exceptions to trap instead, but that
> option is off by default, and it's not always supported, and almost
> nobody uses it even when it is supported because it's a pain to use
> and it's rarely exercised and it tends to be buggy.

AFAIK, Posix and the latest C standards provide fenv.h header and
several functions there, which are in a way a return to the exceptions
model.  So maybe we should use those facilities, where available, to
optionally signal an error, instead of wiping this feature out
completely.

> >  . Do we really want to remove a possibility of signaling an error on
> >    EDOM and ERANGE?
> 
> Yes we do.  Nobody configures Emacs that way (it's not documented
> anywhere), and there's a good reason: it hasn't been needed for
> decades.

But couldn't this be a useful debugging option, like -DGLYPH_DEBUG=1 ?

> >  . The pieces related to 'matherr' might still be needed on platforms
> >    which provide that function....  AFAIR the default version of that
> >    function may print an error message, which I think we need to prevent.
> 
> matherr was a problem back in the 1980s, but it's been obsolete for
> decades.  Platforms that still provide it have it as an SVID option
> that is disabled by default, because it was clearly a mistake.

I'm not sure this is so universally correct.  E.g., what about Cygwin?
Ken, can you tell?  AFAIR, Cygwin uses fdlibm, which used to invoke
matherr by default.

> SVID has been supplanted by POSIX, which does not allow the matherr
> behavior.  Emacs does not enable the obsolete SVID option on any
> platform, so it's fine.

Perhaps you forget that Emacs supports a few non-Posix or marginally
Posix platforms.  E.g., in the MS-Windows and MS-DOS ports, I can
cause FP exception to trigger SIGFPE at run time with a single
function call.  I'm sure glibc has a similar facility as well.