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 {...@@ -18,6 +18,8 @@ const A = struct {
18 e: u5,18 e: u5,
19 f: u16,19 f: u16,
20 g: u16,20 g: u16,
21 h: u9,
22 i: u7,
21};23};
2224
23const P = packed struct {25const P = packed struct {
...@@ -53,6 +55,8 @@ test "@byteOffsetOf" {...@@ -53,6 +55,8 @@ test "@byteOffsetOf" {
53 expect(@ptrToInt(&a.e) - @ptrToInt(&a) == @byteOffsetOf(A, "e"));55 expect(@ptrToInt(&a.e) - @ptrToInt(&a) == @byteOffsetOf(A, "e"));
54 expect(@ptrToInt(&a.f) - @ptrToInt(&a) == @byteOffsetOf(A, "f"));56 expect(@ptrToInt(&a.f) - @ptrToInt(&a) == @byteOffsetOf(A, "f"));
55 expect(@ptrToInt(&a.g) - @ptrToInt(&a) == @byteOffsetOf(A, "g"));57 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"));
56}60}
5761
58test "@byteOffsetOf packed struct, array length not power of 2 or multiple of native pointer width in bytes" {62test "@byteOffsetOf packed struct, array length not power of 2 or multiple of native pointer width in bytes" {