Skip to content

Commit e78d902

Browse files
committed
---
yaml --- r: 34773 b: refs/heads/master c: 7f12cc4 h: refs/heads/master i: 34771: 8784e5c v: v3
1 parent b06755b commit e78d902

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 47c83f1844d033a2ee12aa05eed30112804f4585
2+
refs/heads/master: 7f12cc4e63657155f54fd734c791f66f5f6d9e20
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024

trunk/src/rustc/middle/trans/foreign.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,10 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
112112
Float => 4,
113113
Double => 8,
114114
Struct => {
115-
do vec::foldl(0, struct_tys(ty)) |s, t| {
116-
s + ty_size(*t)
117-
}
115+
let size = do vec::foldl(0, struct_tys(ty)) |s, t| {
116+
align(s, *t) + ty_size(*t)
117+
};
118+
align(size, ty)
118119
}
119120
Array => {
120121
let len = llvm::LLVMGetArrayLength(ty) as uint;

trunk/src/test/run-pass/issue-3656.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Issue #3656
2+
// Incorrect struct size computation in the FFI, because of not taking
3+
// the alignment of elements into account.
4+
5+
use libc::*;
6+
7+
struct KEYGEN {
8+
hash_algorithm: [c_uint]/2,
9+
count: uint32_t,
10+
salt: *c_void,
11+
salt_size: uint32_t,
12+
}
13+
14+
extern {
15+
// Bogus signature, just need to test if it compiles.
16+
pub fn malloc(++data: KEYGEN);
17+
}
18+
19+
fn main() {
20+
}

0 commit comments

Comments
 (0)