Created attachment 11566 [details] Extract and type ./compile to compile the code ... Creates executable testBug Attaching a piece of C++ code which gives wrong floating point result with clang++. But gives correct results in the following compilers (tested) 1) g++ >= 4.2 and 2) icpc > 11.0 Expected output =============== Flux = 0.57735 0.989578 0.412228 0.412228 1.73147 Actual output from clang ========================= Flux = 0.508632 0.797979 0.383204 0.383204 1.20769 This bug is reproducible in clang shipped with Xcode 5.0 on OSX Maverics and clang 3.1-svn. valgrind shows no errors and using -O0 does not help either.
Sorry just now confirmed this bug is visible only with the -O2 flag. So it has to do something with FP optimization. (In reply to comment #0) > Created attachment 11566 [details] > Extract and type ./compile to compile the code ... Creates executable testBug > > Attaching a piece of C++ code which gives wrong floating point result with > clang++. But gives correct results in the following compilers (tested) > 1) g++ >= 4.2 and 2) icpc > 11.0 > > Expected output > =============== > Flux = 0.57735 0.989578 0.412228 0.412228 1.73147 > > Actual output from clang > ========================= > Flux = 0.508632 0.797979 0.383204 0.383204 1.20769 > > This bug is reproducible in clang shipped with Xcode 5.0 on OSX Maverics and > clang 3.1-svn. valgrind shows no errors and using -O0 does not help either.