[Issue 10124] Array length increases on subtraction of a big number instead of throwing RangeError

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Sep 1 11:18:40 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=10124

--- Comment #4 from yebblies <yebblies at gmail.com> ---
Overflow looks the same:

void main()
{
    int[] arr = [1,2,3,4];
    arr.length += uint.max;
}

It's currently being rewritten to 'length = (length op arg)'.  I'm not sure how
to detect this easily without adding inline code, or an overload for each
operation.

I mean, for this:
    arr.length += -3;

the compiler sees this:
    arr.length = arr.length + 4294967293u;

--


More information about the Digitalmars-d-bugs mailing list