d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / gcc / testsuite / gdc.test / fail_compilation / test21665.d
blobb4c28116e340a144d4bf6b9b2e70c06511a283ec
1 /* TEST_OUTPUT:
2 ---
3 fail_compilation/test21665.d(18): Error: `void` initializers for structs with invariants are not allowed in safe functions
4 fail_compilation/test21665.d(30): Error: field `U.s` cannot access structs with invariants in `@safe` code that overlap other fields
5 ---
6 */
8 // https://issues.dlang.org/show_bug.cgi?id=21665
10 struct ShortString {
11 private ubyte length;
12 private char[15] data;
14 invariant { assert(length <= data.length); }
17 @safe void test1() {
18 ShortString s = void;
21 union U
23 int n;
24 ShortString s;
27 @safe void test2()
29 U u;
30 u.s.length = 3;