www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13021] New: Construct union with floating type and then

https://issues.dlang.org/show_bug.cgi?id=13021

          Issue ID: 13021
           Summary: Construct union with floating type and then access its
                    field in one expression causes ICE
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: sinkuu aol.jp

When the union is declared like: the first is a floating point type, the
followings are not floatings, but their sizes are same as first.

Code:
union Fail
{
    float a;
    int b;
}

union Fail2
{
    double a;
    long b;
}

union Fail3
{
    real a;
    struct B { long b1, b2; } // ICE happens only if B.sizeof == real.sizeof
    B b;
}

union Fail4
{
    real a;
    long[2] b; // ditto
}

void main()
{
    auto f = Fail(1.0);  auto ok = f.b;

    // these messages are generated by DMD v2.066-devel-4272838

    auto fail = Fail(1.0).b; // Internal error: e2ir.c 1162
    // auto fail2 = Fail2(1.0).b; // Internal error: e2ir.c 1162
    // auto fail3 = Fail3(1.0).b; // Internal error: e2ir.c 1162
    // auto fail4 = Fail4(1.0).b; // Internal error: backend/el.c 2904
}

Note:
On DMD2.065 and DMD2.064.2, "Fail4" doesn't cause ICE.

--
Jul 02 2014