Comment # 2
on bug 198
from Iain Buclaw
Seems to be something bizarre going on with struct member functions, possibly
only related to instantiated members. Having a bare function works just fine.
ref Vector opOpAssign (ref Vector rthis, Vector operand)
{
rthis.x += operand.x;
rthis.y += operand.y;
rthis.z += operand.z;
return rthis;
}
Either a mismatch between function type and function parameter types are
throwing off the optimizer, or something else is afoot to make it believe that
the 'this' value members can never change.
In gdc-5, all optimisation levels constfold the answer correctly in the
testcase, except for -Og level, which calls f(), but the entire foreach loop
has been reduced to nothing, so it passes Vector(0,0,0) to sum().