December 30, 2021 [Issue 22637] New: stc.conv `to!double` and `parse!double` dont throw on overflow | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: b2.temp@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"); } --- -- |
Copyright © 1999-2021 by the D Language Foundation