This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofNAD Editorial status.
Section: 29.7[c.math]Status:NAD EditorialSubmitter: Ray LischnerOpened: 2002-02-26Last modified: 2016-01-28
Priority:Not Prioritized
View all otherissues in [c.math].
View all issues withNAD Editorial status.
Discussion:
The float versions of the math functions have no meaningful value to return for a range error. The long double versions have a value they can return, but it isn't necessarily the most reasonable value.
Section 26.5 [lib.c.math], paragraph 5, says that C++ "adds float and long double overloaded versions of these functions, with the same semantics," referring to the math functions from the C90 standard.
The C90 standard, in section 7.5.1, paragraph 3, says that functions return "the value of the macro HUGE_VAL" when they encounter a range error. Section 7.5, paragraph 2, defines HUGE_VAL as a macro that "expands to a positive double expression, not necessarily representable as a float."
Therefore, the float versions of the math functions have no way tosignal a range error.[Curaçao: The LWG notes that this isn'tstrictly correct, since errno is set.] The semantics require that theyreturn HUGE_VAL, but they cannot because HUGE_VAL might not berepresentable as a float.
The problem with long double functions is less severe because HUGE_VAL is representable as a long double. On the other hand, it might not be a "huge" long double value, and might fall well within the range of normal return values for a long double function. Therefore, it does not make sense for a long double function to return a double (HUGE_VAL) for a range error.
Proposed resolution:
Curaçao: C99 was faced with a similar problem, which they fixed byadding HUGE_VALF and HUGE_VALL in addition to HUGE_VAL.
C++ must also fix, but it should be done in the context of thegeneral C99 based changes to C++, not via DR. Thus the LWG in Curaçaofelt the resolution should be NAD, FUTURE, but the issue is being heldopen for one more meeting to ensure LWG members not present during thediscussion concur.
Rationale:
Will be fixed as part of more general work in the TR.