From 143144604497b5cc7c70009f9f567117d35b944d Mon Sep 17 00:00:00 2001 From: Matthew Lugg Date: Fri, 6 Mar 2026 16:30:56 +0000 Subject: [PATCH] behavior: disable some tests under the C backend targeting MSVC The bugs here actually exist on master branch too, but they are being caught by the new static assertions which check type size and alignment. It turns out that MSVC's struct/union "pack" pragma and its "align" declspec interact in undocumented ways which are extremely problematic for generated code. Solving this will require changing how the C backend lowers various types; the disabled tests are all tagged unions, but there are also issues with structs with underaligned fields which the behavior tests just happen to not currently be triggering. --- test/behavior/align.zig | 1 + test/behavior/union.zig | 2 ++ 2 files changed, 3 insertions(+) diff --git a/test/behavior/align.zig b/test/behavior/align.zig index a59bed56ba..550d7008b4 100644 --- a/test/behavior/align.zig +++ b/test/behavior/align.zig @@ -18,6 +18,7 @@ test "global variable alignment" { test "large alignment of local constant" { if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; // flaky + if (builtin.zig_backend == .stage2_c and builtin.target.abi == .msvc) return error.SkipZigTest; const x: f32 align(128) = 12.34; try std.testing.expect(@intFromPtr(&x) % 128 == 0); diff --git a/test/behavior/union.zig b/test/behavior/union.zig index 9badc9dabd..faa3f42ea5 100644 --- a/test/behavior/union.zig +++ b/test/behavior/union.zig @@ -148,6 +148,7 @@ const err = @as(anyerror!Agg, Agg{ const array = [_]Value{ v1, v2, v1, v2 }; test "unions embedded in aggregate types" { + if (builtin.zig_backend == .stage2_c and builtin.target.abi == .msvc) return error.SkipZigTest; switch (array[1]) { Value.Array => |arr| try expect(arr[4] == 3), else => unreachable, @@ -2022,6 +2023,7 @@ test "runtime union init, most-aligned field != largest" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_c and builtin.target.abi == .msvc) return error.SkipZigTest; const U = union(enum) { x: u128,