workaround llvm bug for windows alignment

See #302
This commit is contained in:
Andrew Kelley 2017-09-30 23:42:44 -04:00
parent 844e05f619
commit 6f250f568a
2 changed files with 12 additions and 3 deletions

View File

@ -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,

View File

@ -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,