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