Commit 2545f44db0

vegecode <justin.b.alexander1@gmail.com>
2020-07-04 18:56:19
byteOffsetOf add fields to non-packet struct to maintain symmetry
1 parent 0456b21
Changed files (1)
test
stage1
test/stage1/behavior/sizeof_and_typeof.zig
@@ -18,6 +18,8 @@ const A = struct {
     e: u5,
     f: u16,
     g: u16,
+    h: u9,
+    i: u7,
 };
 
 const P = packed struct {
@@ -53,6 +55,8 @@ test "@byteOffsetOf" {
     expect(@ptrToInt(&a.e) - @ptrToInt(&a) == @byteOffsetOf(A, "e"));
     expect(@ptrToInt(&a.f) - @ptrToInt(&a) == @byteOffsetOf(A, "f"));
     expect(@ptrToInt(&a.g) - @ptrToInt(&a) == @byteOffsetOf(A, "g"));
+    expect(@ptrToInt(&a.h) - @ptrToInt(&a) == @byteOffsetOf(A, "h"));
+    expect(@ptrToInt(&a.i) - @ptrToInt(&a) == @byteOffsetOf(A, "i"));
 }
 
 test "@byteOffsetOf packed struct, array length not power of 2 or multiple of native pointer width in bytes" {