Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

false positive 'The left expression of the compound assignment is an unitialized value. The computed value will be garbage. #9556

Open Quuxplusone opened 13 years ago

Quuxplusone commented 13 years ago
Bugzilla Link PR9196
Status NEW
Importance P normal
Reported by Tom M (LetterRip@gmail.com)
Reported on 2011-02-10 20:19:00 -0800
Last modified on 2011-02-11 13:57:01 -0800
Version trunk
Hardware PC All
CC kremenek@apple.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
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();
}
Quuxplusone commented 13 years ago
(In reply to comment #0)
> 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 TOT version of the analyzer doesn't emit a warning for this example.  What
version of the analyzer are you using?