[LLVMbugs] [Bug 16728] New: Semantics of negative zero in fmin and fmax

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jul 28 16:53:07 PDT 2013


            Bug ID: 16728
           Summary: Semantics of negative zero in fmin and fmax
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ambrop7 at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Clang's implementation of fmin/fmax (and possibly other functions) treats
negative zero incompatibly with gcc, and inconsistent with regard to the order
of the arguments. Test case:

#include <math.h>
#include <stdio.h>
int main ()
    printf("%f %f %f %f\n", fmin(-0.0, 0.0), fmin(0.0, -0.0), fmax(-0.0, 0.0),
fmax(0.0, -0.0));

In gcc, the result is, as one might expect:
-0.000000 -0.000000 0.000000 0.000000

But in clang, it is:
0.000000 -0.000000 0.000000 -0.000000

Also note how fmin(-0.0, 0.0) is different from fmin(0.0, -0.0), same goes for

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130728/ec15ba9c/attachment.html>

More information about the llvm-bugs mailing list