[LLVMbugs] [Bug 9196] New: false positive 'The left expression of the compound assignment is an unitialized value. The computed value will be garbage.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 10 18:19:01 PST 2011


http://llvm.org/bugs/show_bug.cgi?id=9196

           Summary: false positive 'The left expression of the compound
                    assignment is an unitialized value.  The computed
                    value will be garbage.
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
        AssignedTo: kremenek at apple.com
        ReportedBy: LetterRip at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Here is a simplified version of the code

void buggy(float rad) {
    float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707,
0.293},
                      {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
    int a;

    /* mult */
    for(a=0; a<7; a++) {
        vec[a][0]*= rad; vec[a][1]*= rad; /* claims bug is here */
    }
}


The left expression of the compound assignment is an unitialized value.  The
computed value will be garbage.


And the actual code, this is from Blender head, file is interface_draw.c



void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float
rad)
{
    float vec[7][2]= {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707,
0.293},
                      {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
    int a;

    /* mult */
    for(a=0; a<7; a++) {
        vec[a][0]*= rad; vec[a][1]*= rad; /* claims bug is here */
    }

    glBegin(mode);

    /* start with corner right-bottom */
    if(roundboxtype & 4) {
        glVertex2f(maxx-rad, miny);
        for(a=0; a<7; a++) {
            glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]);
        }
        glVertex2f(maxx, miny+rad);
    }
    else glVertex2f(maxx, miny);

    /* corner right-top */
    if(roundboxtype & 2) {
        glVertex2f(maxx, maxy-rad);
        for(a=0; a<7; a++) {
            glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]);
        }
        glVertex2f(maxx-rad, maxy);
    }
    else glVertex2f(maxx, maxy);

    /* corner left-top */
    if(roundboxtype & 1) {
        glVertex2f(minx+rad, maxy);
        for(a=0; a<7; a++) {
            glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]);
        }
        glVertex2f(minx, maxy-rad);
    }
    else glVertex2f(minx, maxy);

    /* corner left-bottom */
    if(roundboxtype & 8) {
        glVertex2f(minx, miny+rad);
        for(a=0; a<7; a++) {
            glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]);
        }
        glVertex2f(minx+rad, miny);
    }
    else glVertex2f(minx, miny);

    glEnd();
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list