D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15678 - BigInt("") should fail more prominently
Summary: BigInt("") should fail more prominently
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2016-02-13 02:14 UTC by Ivan Kazmenko
Modified: 2020-03-21 03:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ivan Kazmenko 2016-02-13 02:14:32 UTC
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.
Comment 2 github-bugzilla 2016-02-25 20:49:39 UTC
Commit pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/3ad0489e36819780a5b9c8a486968f6ae2fe73d3
Merge pull request #3995 from quickfur/bigint_bounds

Issue 15678: BigInt("") should not break array bounds
Comment 3 github-bugzilla 2016-02-28 04:44:24 UTC
Commit pushed to revert-3995-bigint_bounds at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/181ea47be7885ad02c7030b4c6b3c3253d8f2223
Revert "Issue 15678: BigInt("") should not break array bounds"
Comment 4 basile-z 2016-02-29 23:57:29 UTC
The bot didn't auto close this one, maybe "fixed" or "fix" missed in the PR title.