Skip to content

Commit 3d51356

Browse files
committed
---
yaml --- r: 81591 b: refs/heads/snap-stage3 c: aa93381 h: refs/heads/master i: 81589: e7f44f2 81587: 492931b 81583: fb4d03e v: v3
1 parent bee48d8 commit 3d51356

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 420b4260b4000af2b1ffb579fb7df5e437e0faa2
4+
refs/heads/snap-stage3: aa93381e1459c5e739fab400ce8f5f83c9466804
55
refs/heads/try: 70152ff55722878cde684ee6462c14c65f2c4729
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/middle/trans/expr.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,6 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
972972

973973
let vt = tvec::vec_types(bcx, base_datum.ty);
974974
base::maybe_name_value(bcx.ccx(), vt.llunit_size, "unit_sz");
975-
let scaled_ix = Mul(bcx, ix_val, vt.llunit_size);
976-
base::maybe_name_value(bcx.ccx(), scaled_ix, "scaled_ix");
977975

978976
let (bcx, base, len) =
979977
base_datum.get_vec_base_and_len(bcx, index_expr.span,
@@ -982,9 +980,9 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
982980
debug2!("trans_index: base {}", bcx.val_to_str(base));
983981
debug2!("trans_index: len {}", bcx.val_to_str(len));
984982

985-
let bounds_check = ICmp(bcx, lib::llvm::IntUGE, scaled_ix, len);
983+
let unscaled_len = UDiv(bcx, len, vt.llunit_size);
984+
let bounds_check = ICmp(bcx, lib::llvm::IntUGE, ix_val, unscaled_len);
986985
let bcx = do with_cond(bcx, bounds_check) |bcx| {
987-
let unscaled_len = UDiv(bcx, len, vt.llunit_size);
988986
controlflow::trans_fail_bounds_check(bcx, index_expr.span,
989987
ix_val, unscaled_len)
990988
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// error-pattern:index out of bounds: the len is 3 but the index is
12+
13+
use std::uint::max_value;
14+
use std::sys::size_of;
15+
16+
fn main() {
17+
let xs = [1, 2, 3];
18+
xs[max_value / size_of::<int>() + 1];
19+
}

0 commit comments

Comments
 (0)