[Cfp-interest 3195] Fwd: [SC22WG14.26260] Can nan set errno?
Fred J. Tydeman
tydeman at tybor.com
Wed Aug 14 08:11:55 PDT 2024
..................Begin Forwarded Message..................
From: Richard Smith <richardsmith at google.com>
To: ISO C <sc22wg14 at open-std.org>
Date: Fri, 2 Aug 2024 16:32:14 -0700
Subject: [SC22WG14.26260] Can nan set errno?
Hi,
The documentation of errno is clear that it can be set to any non-zero
value by a function whose specification doesn't mention errno. The
specification of nan doesn't mention errno. Therefore one might conclude
that nan can choose to set errno to any non-zero value.
However, the specification of nan says that it's equivalent to a call to
strtod, and the specification of strtod *does* mention errno, which
presumably means that the strtod call that a call to nan is equivalent to
must leave errno unchanged (the condition for setting errno to ERANGE is
presumably not met since a NAN value should presumably not be considered to
overflow even if the n-char-sequence doesn't fit in the payload).
So which interpretation wins? Is a call to nan really equivalent to a call
to strtod, or is it allowed to affect errno? (There's a similar situation
for atof, but it explicitly mentions errno in its specification to say that
it may or may not have strtod's effect on errno, so the rule from 7.5/3
that it may be set to any non-zero value doesn't apply.)
Thanks!
Richard
...................End Forwarded Message..................
---
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