aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.dg/torture/pr96435.d
blob: 896b25f7cb4ee9395edb2e46c7154ebff41570bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96435
// { dg-do run }

@safe bool test96435()
{
    int[2] array = [16, 678];
    union U { int i; bool b; }
    U u;
    u.i = 0x81818181;
    assert(array[u.b] == 678);
    return u.b;
}

@safe void main()
{
    auto b = test96435();
    if (b)
        assert(true);
    if (!b)
        assert(false);
}