Re: union alignment

2016-05-21 Thread tsbockman via Digitalmars-d-learn
On Wednesday, 18 May 2016 at 01:46:37 UTC, tsbockman wrote: Shouldn't a union type always have an `alignof` at least as great as the `alignof` for its largest member? Apparently not; it's actually DMD and LDC that are wrong here: http://bugzilla.gdcproject.org/show_bug.cgi?id=226

Re: union alignment

2016-05-21 Thread Iain Buclaw via Digitalmars-d-learn
On Wednesday, 18 May 2016 at 01:46:37 UTC, tsbockman wrote: Shouldn't a union type always have an `alignof` at least as great as the `alignof` for its largest member? On x86, there's a difference between the type alignment and the field alignment. The type align of ulong and double are 8

union alignment

2016-05-17 Thread tsbockman via Digitalmars-d-learn
Is this a bug? --- module app; union Foo(A, B) { A a; B b; } void main() { alias F = Foo!(double, ulong); import std.stdio, std.algorithm; writefln("sizeof: (%s >= %s) == %s", F.sizeof, max(double.sizeof, ulong.sizeof), F.sizeof >= max(double.sizeof,