Bug 15678 – BigInt("") should fail more prominently
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-02-13T02:14:32Z
Last change time
2020-03-21T03:56:41Z
Keywords
pull
Assigned to
No Owner
Creator
Ivan Kazmenko
Comments
Comment #0 by gassa — 2016-02-13T02:14:32Z
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.