[LLVMbugs] [Bug 22688] New: CannotBeNegativeZero() is too optimistic

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 24 20:39:04 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22688

            Bug ID: 22688
           Summary: CannotBeNegativeZero() is too optimistic
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

$ cat badmath.c
#include <math.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char** argv) {
    float x = 0.0f;
    if (argc == 1) x = -0.0f;
    x = sqrtf(x);
    x = sqrtf(x);
    x = sqrtf(x);
    x = sqrtf(x);
    x = sqrtf(x);
    x = sqrtf(x);
    x = x + 0.0;
    int t;
    memcpy(&t, &x, 4);
    if (t == 0) printf("No problem.\n");
    else printf("We have a problem.\n");
    return 0;
}

$ ./clang badmath.c
$ ./a.out 
No problem.

$ ./clang -O1 badmath.c
$ ./a.out 
We have a problem.

-- 
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/20150225/8b981c4e/attachment.html>


More information about the llvm-bugs mailing list