[Issue 22637] New: stc.conv `to!double` and `parse!double` dont throw on overflow
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 30 09:30:19 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22637
Issue ID: 22637
Summary: stc.conv `to!double` and `parse!double` dont throw on
overflow
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: b2.temp at gmx.com
The documentation says:
""
* Throws:
* A $(LREF ConvException) if `source` is empty, if no number could be
* parsed, or if an overflow occurred.
""
The following float literal causes libc strtod to signal overflow inerrno:
"999123254986799969899949354352145897441435999878464164684643513213254364543545634563454199999999999999999999999433212313213119992313453124136468463543543543999999341534654646546464646541341353541999999999965157349999999999320135273486741354354731567431324134999999999999999999999999999999999999999999999135411.9"
But std.conv `to` and `parse` accept it without throwing
---
void main()
{
import std.conv;
auto src =
"999123254986799969899949354352145897441435999878464164684643513213254364543545634563454199999999999999999999999433212313213119992313453124136468463543543543999999341534654646546464646541341353541999999999965157349999999999320135273486741354354731567431324134999999999999999999999999999999999999999999999135411.9";
auto cv1 = parse!double(src);
auto cv2 =
to!double("999123254986799969899949354352145897441435999878464164684643513213254364543545634563454199999999999999999999999433212313213119992313453124136468463543543543999999341534654646546464646541341353541999999999965157349999999999320135273486741354354731567431324134999999999999999999999999999999999999999999999135411.9");
}
---
--
More information about the Digitalmars-d-bugs
mailing list