| ... | @@ -284,3 +284,12 @@ test "@ptrCast undefined value at comptime" { | ... | @@ -284,3 +284,12 @@ test "@ptrCast undefined value at comptime" { |
| 284 | _ = x; | 284 | _ = x; |
| 285 | } | 285 | } |
| 286 | } | 286 | } |
| | 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 | } |