[Issue 4443] Optimizer produces wrong code for statements after loop

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 12 07:58:30 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4443


Don <clugdbug at yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug at yahoo.com.au


--- Comment #1 from Don <clugdbug at yahoo.com.au> 2010-07-12 07:58:26 PDT ---
Reduced test case. The for loop never runs, and gets optimized away, yet it
still corrupts the code. The struct must be large enough that it doesn't fit in
a register. The bug can be disabled in gloop.c, intronvars(), by commenting out
line 2873, but I'm not yet sure what the root cause is. Probably failing to
copy all of the data into the newly created variable.
---
struct Struct4443
{
    int x;
    char[5] unused;
}

void foo4443(Struct4443[] arr, Struct4443 *dest)
{
    for (int i = 0; false; ) {
        int junk = arr[i].x;
    }
    if (dest || arr[$-1].x) {
        *dest = arr[$-1];
    }
}

void main()
{
    Struct4443[1] a;
    Struct4443 info;
    foo4443(a, &info);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list