From 084911d9b376fa9bea2567f53854511adc6d07ec Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 4 Dec 2017 02:04:08 -0500 Subject: [PATCH] add test for @sizeOf on extern and packed unions --- test/cases/union.zig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/cases/union.zig b/test/cases/union.zig index 291384eaeb..fb0ca1238d 100644 --- a/test/cases/union.zig +++ b/test/cases/union.zig @@ -150,3 +150,19 @@ fn testEnumWithSpecifiedAndUnspecifiedTagValues(x: &const MultipleChoice2) { }); } + +const ExternPtrOrInt = extern union { + ptr: &u8, + int: u64 +}; +test "extern union size" { + comptime assert(@sizeOf(ExternPtrOrInt) == 8); +} + +const PackedPtrOrInt = packed union { + ptr: &u8, + int: u64 +}; +test "extern union size" { + comptime assert(@sizeOf(PackedPtrOrInt) == 8); +}