This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Questions about "Handle constant exponents." in gcc/builtins.c


Hi,

On Thu, 18 Mar 2010, Vincent Lefevre wrote:

> On 2010-03-16 16:18:17 +0100, Richard Guenther wrote:
> > pow (a, 0.5) is always expanded to sqrt(a).
> 
> This violates the ISO C99 standard for -0.0.
> 
> According to N1256, F.9.4.4:
> 
>   pow(Â0, y) returns +0 for y > 0 and not an odd integer.
> 
> So, pow(-0.0, 0.5) should return +0. But sqrt(-0.0) should return -0
> according to the IEEE 754 standard (and F.9.4.5 from ISO C99).

Yes, and I don't know why they specified it like that.  After all 
(-0)*(-0)==+0 (not ==-0), so the above definition is internally 
insonsistent.  Defining sqrt(-0) as +0 would be equally inconsistent, but 
at least agree with the pow(-0, 0.5) result.

But unfortunately you are right, this expansion can only be done for 
-fno-signed-zeros.  (FWIW the general expandsion of pow(x,N/2) where N!=1 
is already guarded by unsafe_math, but for N==1 we do it unconditionally).


Ciao,
Michael.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]