Skip to content

Commit 82fa436

Browse files
committed
librustc: Fix field offsets for packed structs.
1 parent 7074592 commit 82fa436

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/librustc/middle/trans/cabi_x86_64.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,15 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
176176
}
177177

178178
fn classify_struct(tys: &[Type],
179-
cls: &mut [RegClass], i: uint,
180-
off: uint) {
179+
cls: &mut [RegClass],
180+
i: uint,
181+
off: uint,
182+
packed: bool) {
181183
let mut field_off = off;
182184
for ty in tys.iter() {
183-
field_off = align(field_off, *ty);
185+
if !packed {
186+
field_off = align(field_off, *ty);
187+
}
184188
classify(*ty, cls, i, field_off);
185189
field_off += ty_size(*ty);
186190
}
@@ -219,7 +223,7 @@ fn classify_ty(ty: Type) -> Vec<RegClass> {
219223
unify(cls, ix + off / 8u, SSEDs);
220224
}
221225
Struct => {
222-
classify_struct(ty.field_types().as_slice(), cls, ix, off);
226+
classify_struct(ty.field_types().as_slice(), cls, ix, off, ty.is_packed());
223227
}
224228
Array => {
225229
let len = ty.array_length();

0 commit comments

Comments
 (0)