www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Bug 226] New: Union alignof is less than the alignof for each of

http://bugzilla.gdcproject.org/show_bug.cgi?id=226

            Bug ID: 226
           Summary: Union alignof is less than the alignof for each of its
                    fields
           Product: GDC
           Version: 5.x
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gdc
          Assignee: ibuclaw gdcproject.org
          Reporter: thomas.bockman gmail.com

On linux, this will:
    FAIL with GDC targeting x86.
    PASS with GDC x86_64, DMD x86, DMD x86_64, LDC x86, and LDC x86_64.

This may be a front end bug, as the Phobos auto tester failed a similar test
for me with DMD on another OS - BSD I think? I can't reproduce that right now
though, so I thought I'd start by filing with the GDC project.

---
import std.algorithm : max;

union Foo(A, B)
{
     A a;
     B b;

    static assert (typeof(this).sizeof  >= max(A.sizeof,  B.sizeof));
    static assert (typeof(this).alignof >= max(A.alignof, B.alignof));
}

void main()
{
    Foo!(double, ulong) foo;
}
---

(Apologies if this behaviour is by design; I tried asking on D.learn, but got
no replies: http://forum.dlang.org/thread/raiyuiefwsrlqlygonjj forum.dlang.org
)

-- 
You are receiving this mail because:
You are watching all bug changes.
May 20 2016