diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-04-24 17:41:47 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-04-25 00:09:24 -0700 |
| commit | 1b90888f576b4863f4a61213a9ca32b97aa57859 (patch) | |
| tree | ecf4d98a6b296b9aa36fd0c20a729413862f6b91 /doc/langref/test_overaligned_packed_struct.zig | |
| parent | 9d64332a5959b4955fe1a1eac793b48932b4a8a8 (diff) | |
| download | zig-1b90888f576b4863f4a61213a9ca32b97aa57859.tar.gz zig-1b90888f576b4863f4a61213a9ca32b97aa57859.zip | |
migrate langref documentation generation to the build system
Diffstat (limited to 'doc/langref/test_overaligned_packed_struct.zig')
| -rw-r--r-- | doc/langref/test_overaligned_packed_struct.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/langref/test_overaligned_packed_struct.zig b/doc/langref/test_overaligned_packed_struct.zig new file mode 100644 index 0000000000..b739b0d407 --- /dev/null +++ b/doc/langref/test_overaligned_packed_struct.zig @@ -0,0 +1,15 @@ +const std = @import("std"); +const expect = std.testing.expect; + +const S = packed struct { + a: u32, + b: u32, +}; +test "overaligned pointer to packed struct" { + var foo: S align(4) = .{ .a = 1, .b = 2 }; + const ptr: *align(4) S = &foo; + const ptr_to_b: *u32 = &ptr.b; + try expect(ptr_to_b.* == 2); +} + +// test |
