public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/43419]  New: gcc replaces pow(x, 0.5) by sqrt(x), invalid when x is -0
@ 2010-03-18 14:08 vincent at vinc17 dot org
  2010-03-18 14:33 ` [Bug middle-end/43419] " vincent at vinc17 dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: vincent at vinc17 dot org @ 2010-03-18 14:08 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 931 bytes --]

gcc replaces pow(x, 0.5) by sqrt(x). This is invalid when x is -0. Indeed,
according to ISO C99 (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).

Testcase:

#include <stdio.h>
#include <math.h>

int main (void)
{
  volatile double x = -0.0;

  printf ("sqrt(-0)    = %g\n", sqrt (x));
  printf ("pow(-0,0.5) = %g\n", pow (x, 0.5));
  return 0;
}


-- 
           Summary: gcc replaces pow(x, 0.5) by sqrt(x), invalid when x is -
                    0
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vincent at vinc17 dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43419


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-02-16 13:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-43419-4@http.gcc.gnu.org/bugzilla/>
2014-02-16 13:18 ` [Bug middle-end/43419] gcc replaces pow(x, 0.5) by sqrt(x), invalid when x is -0 jackie.rosen at hushmail dot com
2010-03-18 14:08 [Bug middle-end/43419] New: " vincent at vinc17 dot org
2010-03-18 14:33 ` [Bug middle-end/43419] " vincent at vinc17 dot org
2010-03-18 14:35 ` matz at gcc dot gnu dot org
2010-03-18 14:42 ` dominiq at lps dot ens dot fr
2010-03-18 14:49 ` matz at gcc dot gnu dot org
2010-03-18 15:31 ` rguenth at gcc dot gnu dot org
2010-03-18 16:08 ` matz at gcc dot gnu dot org
2010-03-18 16:48 ` matz at gcc dot gnu dot org
2010-03-22 14:58 ` jakub at gcc dot gnu dot org
2010-03-22 16:02 ` mikpe at it dot uu dot se
2010-03-25 16:18 ` hjl dot tools at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).