delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/03/16/17:48:57

Date: Thu, 16 Mar 2000 16:39:51 -0600
From: Eric Rudd <rudd AT cyberoptics DOT com>
Subject: Re: Unnormals???
To: djgpp-workers AT delorie DOT com
Message-id: <38D162B7.317C25BF@cyberoptics.com>
Organization: CyberOptics
MIME-version: 1.0
X-Mailer: Mozilla 4.72 [en] (Win95; U)
X-Accept-Language: en
References: <Pine DOT LNX DOT 4 DOT 10 DOT 10003161757070 DOT 22148-100000 AT acp3bf>
Reply-To: djgpp-workers AT delorie DOT com

Hans-Bernhard Broeker wrote:

> > This is not the part of the standard I was worried about.  C89 explicitly
> > required math functions not to crash, but to set errno instead.  What
> > does C99 say about that?

In CD2 (the latest version I have), the following appears:

     7.3.2  Conventions

            [#1] ... An implementation may set errno but is not required to.

One of the earlier drafts of C99 had neither a requirement for errno to be set, nor
a requirement that the math functions complete without "generating any externally
visible exceptions", as C89 specified.  I pointed out in a public comment how this
made it impossible to write robust, portable code, and the committee agreed to put
wording in that the math functions must not crash, but that apparently didn't make
it into CD2, or else I can't find it.

>        7.12.1  Treatment of error conditions
>
>        [#1]  The  behavior  of each of the functions in <math.h> is
>        specified  for  all  representable  values  of   its   input
>        arguments, except where stated otherwise.

Let me hasten to point out that "specified" does not necessarily mean "useful" or
"doesn't crash".  Unfortunately, the notorious Annex F of C99 specifies some
behaviors that I don't consider useful, or even appropriate.  It was the opinion of
one of the correspondants on comp.std.c that rather than being immediately adopted
by the computing community, the new floating-point specifications of C99 will take
a long time to settle down, and may never be entirely accepted.

> > "sqrt(-1)" produces the invalid operation exception.

I believe this conforms to C99, as long as we document it.  However, in my sqrt
implementation, I returned -QNaN and set errno, since the invalid exception was not
documented in C89.

-Eric Rudd
rudd AT cyberoptics DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019