aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/packed-struct.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/behavior/packed-struct.zig')
-rw-r--r--test/behavior/packed-struct.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/behavior/packed-struct.zig b/test/behavior/packed-struct.zig
index 8c34f5741b..540914bd25 100644
--- a/test/behavior/packed-struct.zig
+++ b/test/behavior/packed-struct.zig
@@ -434,3 +434,15 @@ test "@ptrToInt on a packed struct field" {
};
try expect(@ptrToInt(&S.p0.z) - @ptrToInt(&S.p0.x) == 2);
}
+
+test "optional pointer in packed struct" {
+ 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;
+ if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
+
+ const T = packed struct { ptr: ?*const u8 };
+ var n: u8 = 0;
+ const x = T{ .ptr = &n };
+ try expect(x.ptr.? == &n);
+}