Submitter:Fred J. Tydeman
Submission Date:2015-06-23
Document: WG14 N1941
Related: WG14 DR 409 and 473

Summary

After hearing comments from some implementors at the Oslo 2015 WG14 meeting with respect to Defect Report 473, I believe I now know why some vendors have "extra" range errors in the math library.

C11 has: 7.12.1 Treatment of error conditions

#4 Likewise, a range error occurs if the mathematical result of the function cannot be represented in an object of the specified type, due to extreme magnitude.

Paragraph 5 then gives the details on overflow, and paragraph 6 then gives the details on underflow.

That is, overflow or underflow implies range error. However, nothing in those words preclude other things causing a range error.

Now, consider a specific case, 7.12.6.3 The expm1 functions, which has in C11:

A range error occurs if x is too large.

They are reading that as:

For large arguments (of either sign), (independent of overflow) a range error (is required to) occur. That is, this is another reason for a range error (because the standard requires it).

So for them, all four of these cases are range errors:

• expm1(+infinity) => +infinity (exactly)
• expm1(+DBL_MAX) => overflow
• expm1(-DBL_MAX) => -1 (inexact)
• expm1(-infinity) => -1 (exactly)

I believe that the intent of the committee has always been for expm1:

• Only for large positive finite arguments, overflow happens, so a range error occurs.
• Only when overflow happens (for large positive finite arguments), a range error occurs.
• Only when overflow would happen (for large positive finite arguments), a range error occurs.
• A range error only occurs when overflow happens (for large positive finite arguments).

Suggested Technical Corrigendum

Change 7.21.1#4 to:

Likewise, a range error occurs if and only if the mathematical result of the function cannot be represented in an object of the specified type, due to extreme magnitude.

And, perhaps, add a footnote along the lines of:

That means, range errors only occur if there is an overflow or underflow.