x86_64: fix packed struct equality

Closes #22990
This commit is contained in:
Jacob Young
2025-05-31 23:39:35 -04:00
committed by mlugg
parent 9edfccb9a7
commit 6daa37ded9
2 changed files with 29 additions and 2 deletions

View File

@@ -1307,6 +1307,17 @@ test "packed struct equality" {
comptime try S.doTest(x, y);
}
test "packed struct equality ignores padding bits" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
const S = packed struct { b: bool };
var s: S = undefined;
s.b = true;
try std.testing.expect(s != S{ .b = false });
try std.testing.expect(s == S{ .b = true });
}
test "packed struct with signed field" {
var s: packed struct {
a: i2,