[Issue 15678] New: BigInt("") should fail more prominently

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Feb 12 18:14:32 PST 2016


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 at puremagic.com
          Reporter: gassa at 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 at 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.

--


More information about the Digitalmars-d-bugs mailing list