summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/ctfe13612.d
blob: 150f2ac5d913f355934fc77100df1157e5e30485 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
TEST_OUTPUT:
---
fail_compilation/ctfe13612.d(15): Error: function `ctfe13612.S.recurse` CTFE recursion limit exceeded
fail_compilation/ctfe13612.d(20):        called from here: `s.recurse()`
fail_compilation/ctfe13612.d(15):        1000 recursive calls to function `recurse`
fail_compilation/ctfe13612.d(23):        called from here: `(new S).recurse()`
fail_compilation/ctfe13612.d(23):        while evaluating: `static assert((new S).recurse())`
---
*/

class S
{
    int x;
    int recurse()
    {
        S s;
        assert(!x); // Error: class 'this' is null and cannot be dereferenced
        s = new S();
        return s.recurse();
    }
}
static assert(new S().recurse());