lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] MinGW-w64 gcc-6.3.0 std::rint() anomaly


From: Vadim Zeitlin
Subject: Re: [lmi] MinGW-w64 gcc-6.3.0 std::rint() anomaly
Date: Sun, 20 Aug 2017 23:51:11 +0200

On Sun, 20 Aug 2017 21:31:20 +0200 I wrote:

Me> On Sat, 19 Aug 2017 16:36:30 +0000 Greg Chicares <address@hidden> wrote:
Me> 
Me> GC> Vadim--Do you have any idea why 'fenv_lmi_test' fails with MinGW-w64
Me> GC> gcc-6.3.0, whereas it succeeded with earlier versions?
...
Me>  Worse, I don't really know how can a compiler capable of eliminating
Me> function calls like this be trusted at all. And, just to be fair to MinGW
Me> people for once, this is not their problem at all as I can also reproduce
Me> the same bug with the native g++ 6.4 under Linux. And it's still present in
Me> g++ 7.1 too (but not 5.4.1, FWIW). I've created a bug report for it at
Me> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81906 but, again, this doesn't
Me> really help us right now.

 It turns out that it does help us because this bug got closed[*] with "You
must use -frounding-math" and, indeed, building the test with
CXXFLAGS=-frounding-math makes it pass. This option seems to be available
since quite some time, so it shouldn't hurt using it unconditionally, i.e.
without checking gcc version, for the compilation of this test and other
tests using fenv_rounding(), i.e. round_test and round_to_test. I do wonder
whether it should be used for the main program itself however, it never
changes the rounding mode and it seems gcc developers believe that
-fno-rounding-math has non-negligible performance benefits.

 So I think the code using fenv_rounding() should be compiled with some
LMI_CAN_CHANGE_ROUNDING_MODE defined (from command line) and
-frounding-math and declaration of the mutating overload of fenv_rounding()
should be taken inside "#ifdef LMI_CAN_CHANGE_ROUNDING_MODE" guard to
prevent it from being, possibly accidentally, used from anywhere else.

 What do you think?
VZ

[*] Before being reopened for gcc 7 where it is broken even with this flag,
    but this doesn't affect us for now.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]