gcc/testsuite/gdc.test/fail_compilation/fail281.d
raw| 1 | // https://issues.dlang.org/show_bug.cgi?id=2920 |
| 2 | // recursive templates blow compiler stack |
| 3 | // template_29_B. |
| 4 | /* |
| 5 | TEST_OUTPUT: |
| 6 | --- |
| 7 | fail_compilation/fail281.d(15): Error: template instance `fail281.foo!4294966795u` recursive expansion exceeded allowed nesting limit |
| 8 | --- |
| 9 | */ |
| 10 | |
| 11 | template foo(uint i) |
| 12 | { |
| 13 | static if (i > 0) |
| 14 | { |
| 15 | const uint bar = foo!(i - 1).bar; |
| 16 | } |
| 17 | else |
| 18 | { |
| 19 | const uint bar = 1; |
| 20 | } |
| 21 | } |
| 22 | int main() |
| 23 | { |
| 24 | return foo!(uint.max).bar; |
| 25 | } |