From 6f250f568a5d5dd667b9f290ed8afc9412175b1d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 30 Sep 2017 23:42:44 -0400 Subject: [PATCH] workaround llvm bug for windows alignment See #302 --- test/cases/enum.zig | 7 +++++-- test/cases/struct.zig | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/test/cases/enum.zig b/test/cases/enum.zig index 66fe69e02a..492d450fd7 100644 --- a/test/cases/enum.zig +++ b/test/cases/enum.zig @@ -9,8 +9,7 @@ test "enum type" { assert(bar == Bar.B); assert(@memberCount(Foo) == 3); assert(@memberCount(Bar) == 4); - const expected_foo_size = 16 + @sizeOf(usize); - assert(@sizeOf(Foo) == expected_foo_size); + assert(@sizeOf(Foo) == @sizeOf(FooNoVoid)); assert(@sizeOf(Bar) == 1); } @@ -30,6 +29,10 @@ const Foo = enum { Two: Point, Three: void, }; +const FooNoVoid = enum { + One: i32, + Two: Point, +}; const Bar = enum { A, B, diff --git a/test/cases/struct.zig b/test/cases/struct.zig index 308b75672c..a4ba04a870 100644 --- a/test/cases/struct.zig +++ b/test/cases/struct.zig @@ -1,4 +1,5 @@ const assert = @import("std").debug.assert; +const builtin = @import("builtin"); const StructWithNoFields = struct { fn add(a: i32, b: i32) -> i32 { a + b } @@ -257,7 +258,12 @@ test "packed struct 24bits" { assert(@sizeOf(Foo96Bits) == 12); } - var value = Foo96Bits { + // TODO workaround for LLVM bug on windows + // http://lists.llvm.org/pipermail/llvm-dev/2017-September/117864.html + const align_bytes = if (builtin.os == builtin.Os.windows and + builtin.arch == builtin.Arch.x86_64) 32 else @alignOf(Foo96Bits); + + var value align(align_bytes) = Foo96Bits { .a = 0, .b = 0, .c = 0,