Skip to content

Commit 3ce949f

Browse files
committed
test: add test for issue #3319 long double layout behavior
This test documents the behavior of long double type mapping across different platforms: - On macOS x86_64: long double is 16 bytes, mapped to u128 - On FreeBSD i386: long double is 12 bytes (x87 extended precision) - On Linux x86_64: long double is 16 bytes The test shows how structs with aligned fields (like max_align_t) are handled, and documents the cross-platform type size mismatch issue that can cause layout test failures. Related to issue #3319: #3319
1 parent 5ae4b31 commit 3ce949f

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

bindgen-tests/tests/expectations/tests/issue-3319-long-double-layout.rs

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Test for issue #3319: Layout mismatch when Rust can't represent C type exactly
2+
//
3+
// This test documents the scenario where layout tests fail due to:
4+
// - C types that have different sizes on different platforms (e.g., long double)
5+
// - Rust type mapping producing different sizes than libclang reports
6+
//
7+
// On FreeBSD i386:
8+
// - long double is 12 bytes (x87 extended precision)
9+
// - max_align_t has size 20 bytes
10+
// - Rust maps long double to an integer type (not f64)
11+
// - Layout test fails: Rust_size - libclang_size = overflow
12+
//
13+
// On macOS/Linux x86_64:
14+
// - long double is 8 bytes (macOS) or 16 bytes (Linux)
15+
// - This test passes because sizes match
16+
17+
// Test case: Struct with long double field
18+
// This will have different layouts on different platforms
19+
struct test_long_double_layout {
20+
long double value;
21+
};
22+
23+
// Test case: Struct simulating max_align_t on Linux/FreeBSD
24+
// The aligned attributes are recognized, not unknown
25+
struct test_max_align_sim {
26+
long long field1 __attribute__((__aligned__(__alignof__(long long))));
27+
long double field2 __attribute__((__aligned__(__alignof__(long double))));
28+
};

0 commit comments

Comments
 (0)