Debian Codegraph @

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

raw
1 /* REQUIRED_ARGS: -preview=dip1000
2 * TEST_OUTPUT:
3 ---
4 fail_compilation/test20149.d(28): Error: escaping reference to stack allocated value returned by `S('\xff').this(1)`
5 ---
6 */
7
8 // https://issues.dlang.org/show_bug.cgi?id=20149#c10
9
10 @safe:
11
12 struct S
13 {
14 this(int){ }
15
16 char[] opSlice() return
17 {
18 return buf[];
19 }
20
21 char[4] buf;
22 }
23
24 S bar();
25
26 char[] fun()
27 {
28 return S(1)[];
29 }
30
31 void main()
32 {
33 auto x = fun();
34 }