aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/test_overaligned_packed_struct.zig
blob: 8bf52b32970beb3b5bafd705b0601f629ca6c496 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 = &ptr.b;
    try expect(ptr_to_b.* == 2);
}

// test