This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/81906] [7/8 Regression] Calls to rint() wrongly optimized away starting in g++ 6
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 20 Aug 2017 22:00:59 +0000
- Subject: [Bug c++/81906] [7/8 Regression] Calls to rint() wrongly optimized away starting in g++ 6
- Auto-submitted: auto-generated
- References: <bug-81906-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81906
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Vadim Zeitlin from comment #3)
> (In reply to Andrew Pinski from comment #1)
> > You want -frounding-math
>
> OK, thanks, this does indeed solve my immediate problem. However is it
> really normal that the compiler behaviour silently (!) changes like this, in
> backwards incompatible way between versions? I didn't remember seeing this
> change mentioned in gcc 6 release notes and I just reread them again and
> can't find it anywhere. I think changes silently breaking existing working
> (and standard conforming) code should be at the very least prominently
> documented (and, of course, ideally completely avoided IMO, but this ship
> has probably already sailed).
Yes and no. Since this behavior has been documented this way since 4.4.0:
https://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Optimize-Options.html
-frounding-math
Disable transformations and optimizations that assume default floating point
rounding behavior. This is round-to-zero for all floating point to integer
conversions, and round-to-nearest for all other arithmetic truncations. ___This
option should be specified for programs that change the FP rounding mode
dynamically, or that may be executed with a non-default rounding mode.____ This
option disables constant folding of floating point expressions at compile-time
(which may be affected by rounding mode) and arithmetic transformations that
are unsafe in the presence of sign-dependent rounding modes.
Note I add ___. So basically what changed between 5 and 6 was constant folding
of rint. Since that is covered in the documentation, the change itself does
not need to be documented as happening.