https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123078

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jan Schultke from comment #7)
> You seem to be misreading the example.

I don't think so.

You're misinterpreting the behaviour though.
> "-1e-1000" is not an example of overflow, but of floating-point underflow.

Yes. Clearly.

> Before LWG3081, the resulting tiny value would have been in the range of
> representable values, so a value is written. After LWG3081, this is not an
> example of overflow, so a value is written. Either way, a value ought to be
> written, and LWG3081 is irrelevant.

LWG 3081 is still open, so "before LWG3081" is "the standard".

As I wrote in the issue:

"There are conflicting interpretations of "not in the range representable" for
floating-point types. One view is that 1e-10000 and 1e+10000 are outside the
representable range for a 64-bit double-precision double (which has min/max
exponents of -1022 and 1023)."

According to that interpretation, if the result is outside the range of
representable values then the parameter is unmodified. That's what is happening
here. from_chars fails and reports an error, and your uninitialized variable is
not modified, and you print an indeterminate value.

> If std::from_chars doesn't succeed in parsing "-1e-1000", that's an even
> bigger bug than merely not setting the sign bit properly.

It's LWG 3081.

Reply via email to