aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.dg/gdc218.d
blob: 3e7eb16940aa28a997fa3ce42ec1721873550f48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// https://bugzilla.gdcproject.org/show_bug.cgi?id=218
// { dg-do compile }

struct S218a
{
    this(int* pdata_)
    {
        pdata = pdata_;
    }

    void opIndexAssign(int, size_t) { }
    int* pdata;
};

struct S218
{
    S218a getS218a()
    {
        return S218a(data.ptr);
    }

    int[] data;
    int[] tab2;
};

S218 f()
{
    S218 r;

    for(int i = 0; i < 1; ++i)
        r.getS218a()[0] = 0;

    return r;
}

S218 var;

static this()
{
    var = f();
}