digitalmars.D.bugs - [Issue 18248] New: radix overload of std.conv.parse fails to throw
- d-bugmail puremagic.com (32/32) Jan 16 2018 https://issues.dlang.org/show_bug.cgi?id=18248
https://issues.dlang.org/show_bug.cgi?id=18248 Issue ID: 18248 Summary: radix overload of std.conv.parse fails to throw on non-empty range without number Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: issues.dlang jmdavisProg.com Per the documentation for std.conv.parse, parse is supposed to throw if "no character of the input was meaningfully converted." The main overload of parse does this, and the radix overload does if it's given a radix of 10 (since that just calls the main overload) or if the range is empty. However, if you pass it a radix other than 10 and string that is not empty but which does not start with a number, it returns 0 on failure instead of throwing. e.g. this code should throw ---------------- void main() { import std.conv; auto str = ";"; assert(str.parse!uint(16) == 0); // should throw assert(str == ";"); } ---------------- However, it passes. --
Jan 16 2018