| ... | @@ -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 | }; |
| 22 | | 24 | |
| 23 | const P = packed struct { | 25 | const 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 | } |
| 57 | | 61 | |
| 58 | test "@byteOffsetOf packed struct, array length not power of 2 or multiple of native pointer width in bytes" { | 62 | test "@byteOffsetOf packed struct, array length not power of 2 or multiple of native pointer width in bytes" { |