[Issue 18248] New: radix overload of std.conv.parse fails to throw on non-empty range without number
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jan 17 05:40:48 UTC 2018
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 at puremagic.com
Reporter: issues.dlang at 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.
--
More information about the Digitalmars-d-bugs
mailing list