https://issues.dlang.org/show_bug.cgi?id=15678
Issue ID: 15678
Summary: BigInt("") should fail more prominently
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: [email protected]
Reporter: [email protected]
The following test program, compiled with "-boundscheck=off", writes int.max
(2147483647):
-----
import std.bigint, std.stdio;
void main () {
auto a = BigInt ("");
int x = a.toInt ();
writeln (x);
}
-----
With bounds checking enabled, it fails on line 57 of bigint.d for accessing
element 0 of an empty array:
core.exception.RangeError@std\bigint.d(57): Range violation
The error when converting an empty string to a BigInt should be raised
regardless of whether bounds checking is on.
--