Skip to content

fix index out of bounds error of x86_64 ABI #5779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/cabi_x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 10 additions & 0 deletions src/rt/rust_builtin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,16 @@ rust_dbg_extern_identity_TwoU64s(TwoU64s u) {
return u;
}

struct TwoDoubles {
double one;
double two;
};

extern "C" CDECL TwoDoubles
rust_dbg_extern_identity_TwoDoubles(TwoDoubles u) {
return u;
}

extern "C" CDECL double
rust_dbg_extern_identity_double(double u) {
return u;
Expand Down
1 change: 1 addition & 0 deletions src/rt/rustrt.def.in
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ rust_opendir
rust_dbg_extern_identity_u32
rust_dbg_extern_identity_u64
rust_dbg_extern_identity_TwoU64s
rust_dbg_extern_identity_TwoDoubles
rust_dbg_extern_identity_double
rust_dbg_extern_identity_u8
rust_get_rt_env
Expand Down
20 changes: 20 additions & 0 deletions src/test/run-pass/issue-5754.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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 TwoDoubles {
r: float,
i: float
}

extern "C" {
fn rust_dbg_extern_identity_TwoDoubles(arg1: TwoDoubles) -> TwoDoubles;
}

pub fn main() {}