zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

test_overaligned_packed_struct.zig (324B) - Raw


      1 const std = @import("std");
      2 const expect = std.testing.expect;
      3 
      4 const S = packed struct {
      5     a: u32,
      6     b: u32,
      7 };
      8 test "overaligned pointer to packed struct" {
      9     var foo: S align(4) = .{ .a = 1, .b = 2 };
     10     const ptr: *align(4) S = &foo;
     11     const ptr_to_b: *u32 = &ptr.b;
     12     try expect(ptr_to_b.* == 2);
     13 }
     14 
     15 // test