[Cfp-interest 3198] Re: Can nan() set errno?

Fred J. Tydeman tydeman at tybor.com
Wed Aug 14 15:28:51 PDT 2024


On Wed, 14 Aug 2024 10:11:55 -0500 (COT) Fred J. Tydeman wrote:
>
>Subject: [SC22WG14.26260] Can nan set errno?

7.5 Errors <errno.h> has the general statement:

The value of errno may be set to nonzero by a library function call
whether or not there is an error, provided the use of errno is not
documented in the description of the function in this document.

7.12.2 Treatment of error conditions has several specific statements
that apply to all <math.h> functions.  So, overrides the 7.5 general
statement. 

nan() is a <math.h> function, but is not a mathematical function.
strtod() is not a <math.h> function; but it has words about
overflow and underflow in the Returns section (that mirror 7.12.2).

So, what should happen for 
  nan("a_very_long_string_________");
  strtod("NAN(a_very_long_string_________)", nullptr);
when the n-char-sequence is longer than what the nan returned can hold?


---
Fred J. Tydeman        Tydeman Consulting
tydeman at tybor.com      Testing, numerics, programming
+1 (702) 608-6093      Vice-chair of INCITS/C (ANSI "C")
Sample C17+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.



More information about the Cfp-interest mailing list