Debian Codegraph @

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

raw
1 /*
2 TEST_OUTPUT:
3 ---
4 fail_compilation/ctfe10989.d(11): Error: uncaught CTFE exception `object.Exception("abc"c)`
5 fail_compilation/ctfe10989.d(14): called from here: `throwing()`
6 fail_compilation/ctfe10989.d(14): while evaluating: `static assert(throwing())`
7 ---
8 */
9 int throwing()
10 {
11 throw new Exception(['a', 'b', 'c']);
12 return 0;
13 }
14 static assert(throwing());
15
16 /*
17 TEST_OUTPUT:
18 ---
19 fail_compilation/ctfe10989.d(33): Error: uncaught CTFE exception `object.Exception("abc"c)`
20 fail_compilation/ctfe10989.d(36): called from here: `throwing2()`
21 fail_compilation/ctfe10989.d(36): while evaluating: `static assert(throwing2())`
22 ---
23 */
24 int throwing2()
25 {
26 string msg = "abc";
27
28 char[] arr;
29 arr.length = msg.length;
30 arr = arr[0 .. $];
31 arr[] = msg;
32
33 throw new Exception(cast(string)arr);
34 return 0;
35 }
36 static assert(throwing2());