Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/fail20551.d(15): Error: taking address of lazy parameter `e` is not allowed in a `@safe` function
5 fail_compilation/fail20551.d(26): Error: template instance `fail20551.LazyStore!int.LazyStore.opAssign!int` error instantiating
6 ---
7 */
8
9 struct LazyStore(T)
10 {
11 T delegate() @safe dg;
12
13 void opAssign(E)(lazy E e) @safe
14 {
15 dg = cast(typeof(dg)) &e;
16 }
17
18 T test() @safe{ return dg(); }
19 }
20
21 static LazyStore!int f;
22
23 void main(string[] args) @safe
24 {
25 int x = 1;
26 f = x + x + 20 + x * 20;
27 }