[Cfp-interest 3227] Re: Can nan() set errno?
Fred J. Tydeman
tydeman at tybor.com
Sun Aug 18 15:19:29 PDT 2024
On Thu, 15 Aug 2024 18:21:37 -0700 Jim Thomas wrote:
>> On Aug 14, 2024, at 3:28PM, Fred J. Tydeman <tydeman at tybor.com> wrote:
>>
>> 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?
>
>As stated in the strtod Description (7.24.2.6 #5), "the meaning of the n-char sequence is implementation-defined." In particular, it does not need to be represented in the return NaN. An implementation is free to return the same NaN for all n-char sequences.
OK for the return value.
But, is an implementation allowed to indicate an error
(either via errno or the FP exception flags)?
---
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