| 1 |
// https://bugzilla.gdcproject.org/show_bug.cgi?id=198 |
| 2 |
// { dg-do run } |
| 3 |
// { dg-skip-if "needs gcc/config.d" { ! d_runtime } } |
| 4 |
|
| 5 |
struct S198a |
| 6 |
{ |
| 7 |
union |
| 8 |
{ |
| 9 |
float[3] v; |
| 10 |
struct |
| 11 |
{ |
| 12 |
float x; |
| 13 |
float y; |
| 14 |
float z; |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
this(float x_, float y_, float z_) |
| 19 |
{ |
| 20 |
x = x_; |
| 21 |
y = y_; |
| 22 |
z = z_; |
| 23 |
} |
| 24 |
|
| 25 |
ref S198a opOpAssign(string op)(S198a operand) |
| 26 |
if (op == "+") |
| 27 |
{ |
| 28 |
x += operand.x; |
| 29 |
y += operand.y; |
| 30 |
z += operand.z; |
| 31 |
return this; |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
struct S198b |
| 36 |
{ |
| 37 |
@property get() |
| 38 |
{ |
| 39 |
union Buf |
| 40 |
{ |
| 41 |
void[0] result; |
| 42 |
} |
| 43 |
const Buf buf = { }; |
| 44 |
return buf.result; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
struct S198c |
| 49 |
{ |
| 50 |
@property get() |
| 51 |
{ |
| 52 |
union Buf |
| 53 |
{ |
| 54 |
TypeInfo info; |
| 55 |
void[0] result; |
| 56 |
} |
| 57 |
const Buf buf = { }; |
| 58 |
return buf.result; |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
void main() |
| 64 |
{ |
| 65 |
S198a sum = S198a(0, 0, 0); |
| 66 |
|
| 67 |
foreach(size_t v; 0 .. 3) |
| 68 |
sum += S198a(1, 2, 3); |
| 69 |
|
| 70 |
assert(sum.v == [3, 6, 9]); |
| 71 |
} |