[Issue 287] DMD optimization bug arround dynamic array length
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sat Aug 19 02:10:53 PDT 2006
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=287
deewiant at gmail.com changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |deewiant at gmail.com
           Keywords|                            |wrong-code
            Version|0.163                       |0.164
------- Comment #3 from deewiant at gmail.com  2006-08-19 04:10 -------
My reduced version, with some inline comments:
import std.stdio : writefln;
void main() {
        int lng, lngnew;
        int[] arr = new int[1];
        for (int i = 10; i--;) {
                // removing one of the pairs of assignments to lng/lngnew
                // fixes the bug
                lngnew = lng + arr.length;
                lng = lngnew;
                lngnew = lng + arr.length;
                // moving this writefln to anywhere except between either pair
                // of assignments to lng/lngnew fixes the bug
                writefln("%2d %2d %2d", lng, lngnew, arr.length);
                // changing either "lng = lngnew" to the equivalent statement
                // "lng += arr.length" fixes the bug
                lng = lngnew;
        }
}
-- 
    
    
More information about the Digitalmars-d-bugs
mailing list