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 24859 - Floating point constants are not deterministic across platforms
Summary: Floating point constants are not deterministic across platforms
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: LLVM Codegen (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-17 11:06 PDT by Ed Schouten
Modified: 2016-05-10 06:00 PDT (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments
Tarball with testcase and output (98.03 KB, application/gzip)
2015-09-17 11:06 PDT, Ed Schouten
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Schouten 2015-09-17 11:06:00 PDT
Created attachment 14896 [details]
Tarball with testcase and output

If I install exactly the same version of Clang (3.7.0-RELEASE) on Mac OS X, FreeBSD and Linux, all targeting the same platform (x86_64-unknown-cloudabi) and build the same source file at different optimization levels, I get different results. This bug is similar in nature to bug 24734, but the root cause is different. My suspicion is that this is related to FPU rounding modes.

Attached is a tarball that contains a C source file, foo.c, that is a reduced testcase based on libspeex's vbr.c. This testcase has been built on Mac OS X, FreeBSD and Linux, using different optimization modes. As you can see, anything above -O0 yields different results.
Comment 1 Ed Schouten 2016-05-10 06:00:47 PDT
This bug still applies to r269024.

Some more debugging has revealed that this is due to log() being called. If I compile the code with -fno-builtin or change the calls to log() to, say, banana(), the generated output becomes identical again.