https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65425
--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> --- <https://gcc.gnu.org/ml/gcc-patches/2018-10/msg00284.html> has my comments on ways in which libm functions can be "const/pure with exceptions". It would be possible to have attributes to describe the ways in which most libm functions are const apart from rounding mode, exceptions and errno. I didn't discuss there any possibilities relating to functions raising some exceptions but not others, or the possible exceptions depending on -ffinite-math-only. For example, sin can raise inexact and underflow for finite arguments, as well as invalid for infinite arguments; cos can raise inexact for finite arguments but not underflow. Most functions can raise inexact. (There's also the difference between raising exception flags, which is what's available when using standard facilities, and actually generating a signal and calling a signal handler, when using feenableexcept which is a GNU extension. -ftrapping-math covers both at present.)