Skip to content

Commit 9a4e6d0

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 9a4e6d0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bindgen/codegen/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2674,7 +2674,13 @@ 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 &&
2681+
!self.is_forward_declaration() &&
2682+
!self.found_unknown_attr()
2683+
{
26782684
if let Some(layout) = layout {
26792685
let compile_time = ctx.options().rust_features().offset_of;
26802686
let fn_name = if compile_time {

0 commit comments

Comments
 (0)