summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/test18597.d
blob: 66cde58e047b54691e044256b18f96f781d798d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* TEST_OUTPUT:
---
fail_compilation/test18597.d(24): Error: field `Unaligned.p` cannot modify misaligned pointers in `@safe` code
fail_compilation/test18597.d(25): Error: field `Unaligned.p` cannot assign to misaligned pointers in `@safe` code
fail_compilation/test18597.d(26): Error: field `Unaligned.p` cannot assign to misaligned pointers in `@safe` code
---
*/

// https://issues.dlang.org/show_bug.cgi?id=18597

@safe:

align(1)
struct Unaligned
{
align(1):
    ubyte filler;
    int* p;
}

void test()
{
    Unaligned u;
    u.p = new int;
    Unaligned v = Unaligned(0, new int);
    Unaligned w = { p : new int };
}