about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJyun-Yan You <jyyou@cs.nctu.edu.tw>2013-04-08 21:21:11 +0800
committerJyun-Yan You <jyyou.tw@gmail.com>2013-04-13 15:04:30 +0800
commit4ad8ec351afba3bb7b037b24a3bee1589a10780a (patch)
tree70017d6519d989260057e8b808762859a5abaa4a
parent65ff441b3d25d83335dc46ed4ef86421fca29c8d (diff)
downloadrust-4ad8ec351afba3bb7b037b24a3bee1589a10780a.tar.gz
rust-4ad8ec351afba3bb7b037b24a3bee1589a10780a.zip
fix index out of bounds error of x86_64 ABI
-rw-r--r--src/librustc/middle/trans/cabi_x86_64.rs4
-rw-r--r--src/test/run-pass/issue-5754.rs19
2 files changed, 21 insertions, 2 deletions
diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs
index 0e4bf5ce574..fa85588cb0f 100644
--- a/src/librustc/middle/trans/cabi_x86_64.rs
+++ b/src/librustc/middle/trans/cabi_x86_64.rs
@@ -256,10 +256,10 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
                         cls[i] = sse_int_class;
                     } else if is_sse(cls[i]) {
                         i += 1;
-                        while cls[i] == sseup_class { i += 1u; }
+                        while i != e && cls[i] == sseup_class { i += 1u; }
                     } else if cls[i] == x87_class {
                         i += 1;
-                        while cls[i] == x87up_class { i += 1u; }
+                        while i != e && cls[i] == x87up_class { i += 1u; }
                     } else {
                         i += 1;
                     }
diff --git a/src/test/run-pass/issue-5754.rs b/src/test/run-pass/issue-5754.rs
new file mode 100644
index 00000000000..003701b7a20
--- /dev/null
+++ b/src/test/run-pass/issue-5754.rs
@@ -0,0 +1,19 @@
+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct S {
+    r: float
+}
+
+extern "C" {
+    fn rust_dbg_extern_identity_double(arg1: S) -> float;
+}
+
+pub fn main() {}