Skip to content

Commit a5595c8

Browse files
committed
fix: skip layout tests for types with unknown attributes
Types with unknown attributes (found_unknown_attr) may have unpredictable layouts. Skip layout tests to prevent compile-time assertion failures. Fixes #3319
1 parent c5b5226 commit a5595c8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

bindgen/codegen/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2674,7 +2674,10 @@ impl CodeGenerator for CompInfo {
26742674
}
26752675
}
26762676

2677-
if ctx.options().layout_tests && !self.is_forward_declaration() {
2677+
// Skip layout tests for types with unknown attributes that may affect layout.
2678+
// This prevents incorrect compile-time assertions for types like max_align_t
2679+
// where the layout may differ between platforms. See issue #3319.
2680+
if ctx.options().layout_tests && !self.is_forward_declaration() && !self.found_unknown_attr() {
26782681
if let Some(layout) = layout {
26792682
let compile_time = ctx.options().rust_features().offset_of;
26802683
let fn_name = if compile_time {

0 commit comments

Comments
 (0)