[Bug c++/91099] constexpr vs -frounding-math

glisse at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 27 07:20:01 GMT 2021


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

Marc Glisse <glisse at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> ---
Interestingly, Jakub's patch has the same issue my patch here had: "defeated by
constexpr-caching if we change flag_rounding_math in the middle of a
translation unit".

constexpr double f(){return 1./3.;}
#if BUG
__attribute__((optimize("no-rounding-math")))
double g(){
  double d=f();
  return d;
}
#endif
__attribute__((optimize("rounding-math")))
double h(){
  double d=f();
  return d;
}

The presence of g changes the code we generate for h. At least we don't seem to
reuse the cache from a different value of manifestly_const_eval, so maybe
changing rounding_math is just not supported and this goes in the list of
issues with attribute optimize.


More information about the Gcc-bugs mailing list