Debian Codegraph @

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

raw
1 /*
2 REQUIRED_ARGS: -preview=dip1000 -de
3 TEST_OUTPUT:
4 ---
5 fail_compilation/system_ptr_cast.d(20): Deprecation: cast from `S*` to `int*` will become `@system` in a future release
6 fail_compilation/system_ptr_cast.d(20): Source element type has unsafe bit patterns and target element type is mutable
7 fail_compilation/system_ptr_cast.d(24): Deprecation: cast from `int*` to `S*` will become `@system` in a future release
8 fail_compilation/system_ptr_cast.d(24): Target element type has unsafe bit patterns
9 ---
10 */
11
12 struct S
13 {
14 @system int i;
15 }
16
17 void main() @safe
18 {
19 S s;
20 auto p = cast(int*) &s;
21 *p = 8;
22
23 int i = 8;
24 auto ps = cast(S*) &i;
25 }