[Bug 198] Optimization makes incorrect results

via D.gnu d.gnu at puremagic.com
Mon Sep 14 00:11:24 PDT 2015


--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject.org> ---
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().

You are receiving this mail because:
You are watching all bug changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/d.gnu/attachments/20150914/aacb3cb3/attachment.html>

More information about the D.gnu mailing list