Skip to content

Commit 5ac0381

Browse files
yshuiemilio
authored andcommitted
Use field align if it's smaller than pack align
Fixes #2695
1 parent 8fffbf8 commit 5ac0381

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: bindgen/codegen/struct_layout.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,10 @@ impl<'a> StructLayoutTracker<'a> {
212212
0
213213
} else if !self.is_packed {
214214
self.padding_bytes(field_layout)
215-
} else if let Some(l) = self.known_type_layout {
215+
} else if let Some(mut l) = self.known_type_layout {
216+
if field_layout.align < l.align {
217+
l.align = field_layout.align;
218+
}
216219
self.padding_bytes(l)
217220
} else {
218221
0

0 commit comments

Comments
 (0)