LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 17988 - incorrect floating point results
Summary: incorrect floating point results
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: unspecified
Hardware: Macintosh MacOS X
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-18 23:31 PST by Pavanakumar Mohanamuraly
Modified: 2016-04-25 17:37 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
Extract and type ./compile to compile the code ... Creates executable testBug (10.00 KB, application/x-bzip2)
2013-11-18 23:31 PST, Pavanakumar Mohanamuraly
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pavanakumar Mohanamuraly 2013-11-18 23:31:42 PST
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.
Comment 1 Pavanakumar Mohanamuraly 2013-11-19 01:03:18 PST
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.