Skip to content

Commit 508294e

Browse files
committed
add behavior test for comptime ptrcast packed struct
closes #9912
1 parent 2936602 commit 508294e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/behavior/ptrcast.zig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,12 @@ test "@ptrCast undefined value at comptime" {
284284
_ = x;
285285
}
286286
}
287+
288+
test "comptime @ptrCast with packed struct leaves value unmodified" {
289+
const S = packed struct { three: u3 };
290+
const st: S = .{ .three = 6 };
291+
try expect(st.three == 6);
292+
const p: *const [1]u3 = @ptrCast(&st);
293+
try expect(p.*[0] == 6);
294+
try expect(st.three == 6);
295+
}

0 commit comments

Comments
 (0)