[Issue 12928] Range check dropped for array[length]

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jun 15 21:41:02 PDT 2014


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

--- Comment #2 from Lionello Lunesu <lio+bugzilla at lunesu.com> ---
(In reply to Jonathan M Davis from comment #1)
> On 64-bit Linux with the latest git master, this works perfectly fine for
> me. It throws a RangeError like it's supposed to.

You'll need the very latest to repro the test case,
34d970836b202f71d0a07c4b2a195a405b69bc6d.

Before that commit the compiler didn't know the range of the foreach iterator
and would keep the bounds check. Here's a way to repro on older versions:

void main(string[] args)
{
  int[3] a;
  a[args.length&3] = 2;
}

--


More information about the Digitalmars-d-bugs mailing list