BZ #171: Floating point calculations depend on compiler optimization settings

Status fields:

creation_ts:2012-09-09 22:26
component:native
version:1.6.0
rep_platform:x86_64
op_sys:All
bug_status:RESOLVED
resolution:INVALID
reporter:stefan@complang.tuwien.ac.at
Observed on Fedora 17 x86_64, gcc version 4.7.0 20120507 (Red Hat 4.7.0-5)

With --disable-optimization (-O0), the result of the regression tests is:

fptest: FAILED
--- ./fptest.output.cp  2012-09-05 00:26:20.544807423 +0200
+++ fptest.thisoutput   2012-09-09 10:45:43.251397732 +0200
@@ -947,5 +947,5 @@
  945.    5.0 - MIN = double: 5.0
  946.    5.0 * MIN = double: 2.5E-323
  947.    5.0 / MIN = double: Infinity
- 948.    5.0 % MIN = double: 0.0
+ 948.    5.0 % MIN = double: 2.1729236859025E-311
  949.

Without said configure switch (-O2), the test passes.

Comment #1 by stefan@complang.tuwien.ac.at on 2012-09-10 21:29:23

Seems to be related to the dynamic linker.

Comment #2 by stefan@complang.tuwien.ac.at on 2012-09-10 22:47:40

It only happens when --disable-libjvm is not used (that is, when a dynamic libjvm.so is
built). Contrary to what might be expected, the function __ieee754_fmod from fdlibm
inside the CACAO source tree is not used in this case. Instead, glibc seems to have its
own copy of this function, and this got broken in this "optimization" [1], and that's
what Fedora shipped in F17. Seems to be fixed by now [2]. Did I mention that I hate the
global namespace of shared libraries on Unix? It's useful for being able to divert some
functions with LD_PRELOAD, but other than that I think it's brain-damaged.

[1] http://sourceware.org/git/?p=glibc.git;a=commit;h=0275fff8a105d5963df43b27df769487ad
ac25ac>
[2] http://sourceware.org/bugzilla/show_bug.cgi?id=14048