ldc/tests/codegen/gh2235.d
kinke ab37d5ba99 Fix issue #2235 - IR struct packedness (#2247)
Unnaturally aligned aggregates were potentially not marked as packed,
leading to LLVM inserting additional padding and screwing up the memory
layout.
2017-08-11 19:05:09 +02:00

29 lines
429 B
D

// RUN: %ldc -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
// RUN: %ldc -run %s
// CHECK: %gh2235.Foo = type <{
align(2) struct Foo {
long y;
byte z;
}
// CHECK: %gh2235.Bar = type <{
class Bar {
union {
bool b;
Foo foo;
}
byte x;
void set(Foo f) {
x = 99;
foo = f;
}
}
void main() {
Bar bar = new Bar();
Foo f;
bar.set(f);
assert(bar.x == 99);
}