1 /* https://issues.dlang.org/show_bug.cgi?id=15399
2 ---
3 fail_compilation/test15399.d(31): Error: writing to misaligned pointer in field S1.ptr is not @safe
4 fail_compilation/test15399.d(32): Error: writing to misaligned pointer in field S2.ptr is not @safe
5 fail_compilation/test15399.d(33): Error: taking address of misaligned pointer in field S1.ptr is not @safe
6 fail_compilation/test15399.d(34): Error: taking address of misaligned pointer in field S2.ptr is not @safe
7 fail_compilation/test15399.d(35): Error: 'ref' of misaligned pointer in field S1.ptr is not @safe
8 fail_compilation/test15399.d(36): Error: 'ref' of misaligned pointer in field S2.ptr is not @safe
9 fail_compilation/test15399.d(37): Error: 'out' of misaligned pointer in field S1.ptr is not @safe
10 fail_compilation/test15399.d(38): Error: 'out' of misaligned pointer in field S2.ptr is not @safe
11 ---
12 */
13 
14 struct S1
15 {
16         char c;
17     align (1)
18         int* ptr;
19 }
20 
21 align (1)
22 struct S2
23 {
24     int* ptr;
25 }
26 
test(S1 * s1,S2 * s2)27 @safe void test(S1* s1, S2* s2)
28 {
29     int* p = s1.ptr;
30     p = s2.ptr;
31     s1.ptr = null;
32     s2.ptr = null;
33     int** pp = &s1.ptr;
34     pp = &s2.ptr;
35     bar(s1.ptr);
36     bar(s2.ptr);
37     sinister(s1.ptr);
38     sinister(s2.ptr);
39     cbar(s1.ptr);
40     cbar(s2.ptr);
41 }
42 
43 @safe void bar(ref int*);
44 @safe void cbar(ref const int*);
45 @safe void sinister(out int*);
46 
47