authorgravatar for justin.b.alexander1@gmail.comvegecode <justin.b.alexander1@gmail.com> 2020-07-04 11:56:19-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-16 20:04:42-07:00
log2545f44db0ce3e88dc9c59a9cbb18e67e02cc1e4
tree23b09d503fe6384286bee704d3ddf7486cde976f
parent0456b2145de52bf0da3a18cfa3313ca42d7afd29

byteOffsetOf add fields to non-packet struct to maintain symmetry


1 files changed, 4 insertions(+), 0 deletions(-)

test/stage1/behavior/sizeof_and_typeof.zig+4
......@@ -18,6 +18,8 @@ const A = struct {
1818 e: u5,
1919 f: u16,
2020 g: u16,
21 h: u9,
22 i: u7,
2123};
2224
2325const P = packed struct {
......@@ -53,6 +55,8 @@ test "@byteOffsetOf" {
5355 expect(@ptrToInt(&a.e) - @ptrToInt(&a) == @byteOffsetOf(A, "e"));
5456 expect(@ptrToInt(&a.f) - @ptrToInt(&a) == @byteOffsetOf(A, "f"));
5557 expect(@ptrToInt(&a.g) - @ptrToInt(&a) == @byteOffsetOf(A, "g"));
58 expect(@ptrToInt(&a.h) - @ptrToInt(&a) == @byteOffsetOf(A, "h"));
59 expect(@ptrToInt(&a.i) - @ptrToInt(&a) == @byteOffsetOf(A, "i"));
5660}
5761
5862test "@byteOffsetOf packed struct, array length not power of 2 or multiple of native pointer width in bytes" {