Commit 6f250f568a

Andrew Kelley <superjoe30@gmail.com>
2017-10-01 05:42:44
workaround llvm bug for windows alignment
See #302
1 parent 844e05f
Changed files (2)
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,
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,