Skip to content

Commit fae51b8

Browse files
committed
---
yaml --- r: 95422 b: refs/heads/dist-snap c: aa93381 h: refs/heads/master v: v3
1 parent 6e33cb9 commit fae51b8

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
@@ -6,7 +6,7 @@ refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 420b4260b4000af2b1ffb579fb7df5e437e0faa2
9+
refs/heads/dist-snap: aa93381e1459c5e739fab400ce8f5f83c9466804
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/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)