gcc/testsuite/gdc.test/fail_compilation/const_ctor.d
raw| 1 | /* |
| 2 | TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/const_ctor.d(23): Error: `const` copy constructor `const_ctor.S1.this` cannot construct a mutable object |
| 5 | fail_compilation/const_ctor.d(25): Error: `const` constructor `const_ctor.S2.this` cannot construct a mutable object |
| 6 | --- |
| 7 | */ |
| 8 | |
| 9 | struct S1 |
| 10 | { |
| 11 | this(ref const S1 s) const {} |
| 12 | int* i; |
| 13 | } |
| 14 | struct S2 |
| 15 | { |
| 16 | this(int) const {} |
| 17 | int* i; |
| 18 | } |
| 19 | |
| 20 | void main() |
| 21 | { |
| 22 | const(S1) s1; |
| 23 | S1 m1 = s1; |
| 24 | |
| 25 | S2 s2 = S2(5); |
| 26 | } |