Debian Codegraph @

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

raw
1 /* TEST_OUTPUT:
2 ---
3 fail_compilation/test18597.d(24): Error: modifying misaligned pointers through field `Unaligned.p` is not allowed in a `@safe` function
4 fail_compilation/test18597.d(25): Error: field `Unaligned.p` assigning to misaligned pointers is not allowed in a `@safe` function
5 fail_compilation/test18597.d(26): Error: field `Unaligned.p` assigning to misaligned pointers is not allowed in a `@safe` function
6 ---
7 */
8
9 // https://issues.dlang.org/show_bug.cgi?id=18597
10
11 @safe:
12
13 align(1)
14 struct Unaligned
15 {
16 align(1):
17 ubyte filler;
18 int* p;
19 }
20
21 void test()
22 {
23 Unaligned u;
24 u.p = new int;
25 Unaligned v = Unaligned(0, new int);
26 Unaligned w = { p : new int };
27 }