Skip to content

Commit

Permalink
Merge pull request #3671 from lionello/bug12928
Browse files Browse the repository at this point in the history
Issue 12928 - Range check dropped for array[length]
  • Loading branch information
9rnsr committed Jun 17, 2014
2 parents 5cc1c81 + fc5fc7d commit 25e77d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/expression.c
Expand Up @@ -10765,7 +10765,7 @@ Expression *IndexExp::semantic(Scope *sc)
e2 = e2->optimize(WANTvalue);
dinteger_t length = el->toInteger();
if (length)
skipboundscheck = IntRange(SignExtendedNumber(0), SignExtendedNumber(length)).contains(getIntRange(e2));
skipboundscheck = IntRange(SignExtendedNumber(0), SignExtendedNumber(length-1)).contains(getIntRange(e2));
}
}

Expand Down
13 changes: 13 additions & 0 deletions test/runnable/bug12928.d
@@ -0,0 +1,13 @@
// PERMUTE_ARGS: -inline -g -O
import core.exception : RangeError;
void main(string[] args)
{
int[2] a;
try
{
foreach(const i; 0..3)
a[i] = i;
assert(0);
}
catch(RangeError){}
}

0 comments on commit 25e77d3

Please sign in to comment.