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

void main()
{
    struct S101282
    {
        int impl;
        S101282 opUnary(string op : "-")()
        {
            return S101282(-impl);
        }
        int opCmp(int i)
        {
            return (impl < i) ? -1 : (impl > i) ? 1 : 0;
        }
    }
    auto a = S101282(120);
    a = -a;
    assert(a.impl == -120);
    a = a >= 0 ? a : -a;
    assert(a.impl == 120);
}