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

            Bug ID: 19174
           Summary: -O1 breaks std::abs
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

The appended snippet, when compiled and executed thus:

  clang++ -o a.out t.cpp -O1 && ./a.out

produces the following output:

  z: -1372777060 abs(z): -1372777060

Removing -O1 results in the correct output. 

My clang version:

  Ubuntu clang version 3.5.0-1~exp1 (trunk) (based on LLVM 3.5.0)
  Target: x86_64-pc-linux-gnu
  Thread model: posix


#include <cmath>
#include <cstdlib>
#include <iostream>

int main ()
{
  int z = std::rand () * 4;
  std::cout << "z: " << z << " abs(z): " << std::abs (z) << std::endl;
  return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to