diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-07-27 22:04:00 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-27 22:04:00 -0700 |
| commit | c650ccfca719b695fe7752f9126e8dbcc2ab4d6d (patch) | |
| tree | dc112b2472f53e44e377dee68d30db02caed8c03 /test/behavior/packed-struct.zig | |
| parent | dfc7493dcb049788b92137ca09b8bd47cee23865 (diff) | |
| parent | 3ccb6a0cd4d4f436a6009ed614436bb3e2e27a7c (diff) | |
| download | zig-c650ccfca719b695fe7752f9126e8dbcc2ab4d6d.tar.gz zig-c650ccfca719b695fe7752f9126e8dbcc2ab4d6d.zip | |
Merge pull request #12265 from ziglang/stage3-run-translated-c
CI: test-run-translated-c with stage3
Diffstat (limited to 'test/behavior/packed-struct.zig')
| -rw-r--r-- | test/behavior/packed-struct.zig | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/behavior/packed-struct.zig b/test/behavior/packed-struct.zig index 52083a492d..2dea485bf5 100644 --- a/test/behavior/packed-struct.zig +++ b/test/behavior/packed-struct.zig @@ -436,3 +436,25 @@ test "load pointer from packed struct" { try expect(i == 123); } } + +test "@ptrToInt on a packed struct field" { + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; + + const S = struct { + const P = packed struct { + x: u8, + y: u8, + z: u32, + }; + var p0: P = P{ + .x = 1, + .y = 2, + .z = 0, + }; + }; + try expect(@ptrToInt(&S.p0.z) - @ptrToInt(&S.p0.x) == 2); +} |
