https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104824
Bug ID: 104824
Summary: std::comp_ellint1 handles domain error incorrectly
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
The standard defines std::comp_ellint1 for |k| <= 1, but we do:
else if (std::abs(__k) >= _Tp(1))
return std::numeric_limits<_Tp>::quiet_NaN();
This is the wrong condition, and is not the correct way to report the error.
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."
Other special functions throw std::domain_error, which isn't right either.
We should check all the domains, and fix the method of error reporting.