https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67603

            Bug ID: 67603
           Summary: [aarch64] constant folded of floating-point expression
                    at compile-time value does not match run-time value
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david.abdurachmanov at gmail dot com
  Target Milestone: ---

Created attachment 36344
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36344&action=edit
standalone testcase

This was noticed in Fedora 23 AArch64, HepMC package was failing test --
testSimpleVector

Simplified testSimpleVector version is attached.

Compile: g++ -ansi -pedantic -Wall -g -O2 -o testSimpleVector
testSimpleVector.cc

Seems to fail on GCC 4.9.3, 5.2.0, trunk (r227832).

According to documentation -frounding-math disables const folding for floating
expression and it does resolve the issue, i.e. test is no more failing.

 72   namas::FourVector vector;
 73   namas::FourVector v4(1.1,2.2,3.3,4.4);
 74
 75   vector = v4;
 76   double masssq1 = v4.m2();
 77   double eta1 = v4.eta();
 78   double masssq2 = vector.m2();

v4.m2() get const folded at compile-time, but vector.m2() is computed at
run-time. The test fails because compile-time and run-time values are
"significantly" different, i.e. the difference is above 1.e-15.

vector.m2():  2.4200000000000017
v4.m2(): 2.4200000000000053 (from literal pool)

Why is that compiler cannot achieve the same result as at run-time?

Reply via email to