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"); } ---
I can't confirm this bug on my end. It throws `std.conv.ConvException@C:\LDC\bin\..\import\std\conv.d(3419): Range error` for me. LDC - the LLVM D compiler (1.29.0): based on DMD v2.099.1 and LLVM 13.0.1
I was able to reproduce the bug with DMD 2.100.0 and LDC 1.29.0 on Linux. From the backslashes in the path, it appears that the failed reproduction attempt was on Windows, so it's possible this bug only occurs on Linux.
@GrimMaple created dlang/phobos pull request #8502 "Fix Issue 22637 - std.conv `to!double` and `parse!double` dont throw on under/overflow" fixing this issue: - Fix Issue 22637 - std.conv `to!double` and `parse!double` dont throw on under/overflow This happened because `parse` enforced on real. And provided number actually fits real. Changed to enforce on `Target` type instead https://github.com/dlang/phobos/pull/8502
dlang/phobos pull request #8502 "Fix Issue 22637 - std.conv `to!double` and `parse!double` dont throw on under/overflow" was merged into master: - 1c3903c2e644d55913708b6867e33aab1a076ac9 by Grim Maple: Fix Issue 22637 - std.conv `to!double` and `parse!double` dont throw on under/overflow This happened because `parse` enforced on real. And provided number actually fits real. Changed to enforce on `Target` type instead https://github.com/dlang/phobos/pull/8502