https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104824
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2022-03-08 Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #0) > Reporting a domain error should be done as specified by C: > > "On a domain error, the function returns an implementation-defined value; if > the integer expression math_errhandling & MATH_ERRNO is nonzero, the integer > expression errno acquires the value EDOM; if the integer expression > math_errhandling & MATH_ERREXCEPT is nonzero, the “invalid” floating-point > exception is raised." Additionally: "If a domain, pole, or range error occurs and the integer expression math_errhandling & MATH_ERRNO is zero,237) then errno shall either be set to the value corresponding to the error or left unmodified. If no such error occurs, errno shall be left unmodified regardless of the setting of math_errhandling." We can just set errno unconditionally, and conditionally also do feraiseexcept(FE_INVALID).