<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="moz-cite-prefix">On 8/18/2024 18:19, Fred J. Tydeman
wrote:<br>
</div>
<blockquote type="cite" cite="mid:100.98f20b007173c266.003@tybor.com"><span style="white-space: pre-wrap">OK for the return value.</span>
<pre class="moz-quote-pre" wrap="">But, is an implementation allowed to indicate an error
(either via errno or the FP exception flags)?
</pre>
</blockquote>
<p>The interpretation I gave when asked this question a few weeks
ago was this:</p>
<p dir="auto"><code class="notranslate">strotod</code> says for NaN
sequences:</p>
<blockquote>
<p dir="auto">A character sequence <code class="notranslate">NAN</code>
or <code class="notranslate">NAN(n-char-sequenceopt)</code> is
interpreted as a quiet NaN, if supported in the return type,
else like a subject sequence part that does not have the
expected form; the meaning of the n-char sequence<br>
is implementation-defined.</p>
</blockquote>
<p dir="auto">It gives explicit rules for overflow and underflow,
which can set <code class="notranslate">errno</code> values, but
is silent on what happens with the n-char sequence being out of
range of the payload, outside of the above quote. But... there's
not really any latitude I see in the specification for <code class="notranslate">errno</code> to be set (unless you think
7.12.1 applies to <code class="notranslate">nan</code> and sNaN
is a domain error).</p>
<p dir="auto">glibc fails because it's using <code class="notranslate">strtoull</code> here, and <code class="notranslate">strtoull</code> does <code class="notranslate">ERANGE</code> on overflow. But I think this
is a glibc bug, it shouldn't be setting errno. [This bug was filed
as <a class="moz-txt-link-freetext" href="https://sourceware.org/bugzilla/show_bug.cgi?id=32045">https://sourceware.org/bugzilla/show_bug.cgi?id=32045</a>, there's
been no discussion on the bug yet.]</p>
<p dir="auto"><br>
</p>
<p dir="auto">If this interpretation is correct, it wouldn't be a
bad idea to add a note saying that strtod converting to nans or
the nan function can't return errno; if it's not correct, then
normative text should be added to cover the errno case.<br>
</p>
<p></p>
</body>
</html>