mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
28 lines
613 B
Zig
28 lines
613 B
Zig
const std = @import("std");
|
|
const builtin = @import("builtin");
|
|
|
|
const B = union(enum) {
|
|
D: u8,
|
|
E: u16,
|
|
};
|
|
|
|
const A = union(enum) {
|
|
B: B,
|
|
C: u8,
|
|
};
|
|
|
|
test "union that needs padding bytes inside an array" {
|
|
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
|
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
|
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
|
|
|
var as = [_]A{
|
|
A{ .B = B{ .D = 1 } },
|
|
A{ .B = B{ .D = 1 } },
|
|
};
|
|
_ = &as;
|
|
|
|
const a = as[0].B;
|
|
try std.testing.expect(a.D == 1);
|
|
}
|