Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/fail10666.d

raw
1 // REQUIRED_ARGS: -c
2 /*
3 TEST_OUTPUT:
4 ---
5 fail_compilation/fail10666.d(16): Error: variable `fail10666.foo10666.s1` has scoped destruction, cannot build closure
6 ---
7 */
8
9
10 struct S10666
11 {
12 int val;
13 ~this() {}
14 }
15
16 void foo10666(S10666 s1)
17 {
18 auto f1 = (){ return () => s1.val; }(); // NG
19
20 S10666 s2;
21 auto f2 = (){ return () => s2.val; }(); // (should be NG)
22 }