Skip to content

Commit dc9764e

Browse files
committed
---
yaml --- r: 35966 b: refs/heads/try2 c: 7f12cc4 h: refs/heads/master v: v3
1 parent 7e2a016 commit dc9764e

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 47c83f1844d033a2ee12aa05eed30112804f4585
8+
refs/heads/try2: 7f12cc4e63657155f54fd734c791f66f5f6d9e20
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/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;
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)