www.digitalmars.com         C & C++   DMDScript  

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


          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

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