This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Gcc floating-point optimizer weird behaviour


On 2015-01-25 20:51:33 +0300, Vladimir A. Pavlov wrote:
> I have two files (a.c and f.c, look below). In a.c:main() there are two
> variables, d and e, assigned the same function call result. But the
> optimizer causes their values to be different.

Concerning this particular point, I don't think that there is
a guarantee that you will get the same result, even if you use
-fexcess-precision=standard. At least there is no guarantee
from the C standard. Functions can be inlined, and optimizations
can be done in different ways because the context is different.

If you want reproducible results, make sure that IEEE 754 is
supported and that the FP_CONTRACT pragma is set to OFF
(but impossible with GCC: see PR 37845).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]