Skip to content

Commit

Permalink
workaround llvm bug for windows alignment
Browse files Browse the repository at this point in the history
See #302
  • Loading branch information
andrewrk committed Oct 1, 2017
1 parent 844e05f commit 6f250f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions test/cases/enum.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -30,6 +29,10 @@ const Foo = enum {
Two: Point,
Three: void,
};
const FooNoVoid = enum {
One: i32,
Two: Point,
};
const Bar = enum {
A,
B,
Expand Down
8 changes: 7 additions & 1 deletion test/cases/struct.zig
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 6f250f5

Please sign in to comment.