summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/fail_compilation/test13536.d
blob: 800757dcf6c4ae404f4bad8b51a938ab948a72ec (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
/*
PERMUTE_ARGS:
TEST_OUTPUT:
---
fail_compilation/test13536.d(24): Error: field U.sysDg cannot access pointers in @safe code that overlap other fields
fail_compilation/test13536.d(24): Error: address of variable `s` assigned to `u` with longer lifetime
fail_compilation/test13536.d(25): Error: field U.safeDg cannot access pointers in @safe code that overlap other fields
---
*/


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

struct S {
    void sysMethod() @system {}
}
void fun() @safe {
    union U {
        void delegate() @system sysDg;
        void delegate() @safe safeDg;
    }
    U u;
    S s;
    u.sysDg = &s.sysMethod;
    u.safeDg();
}