www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15678] New: BigInt("") should fail more prominently

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: nobody puremagic.com
          Reporter: gassa mail.ru

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.

--
Feb 12 2016