Menu

Unitialised value usage

2015-03-13
2015-03-14
  • AnotherUser

    AnotherUser - 2015-03-13

    Dear Cppcheck developers,

    I noticed a false negative when working with multidimensional arrays. I was not able to find an exact ticket for this in trac, the closest I can find are tickets #3545 and #4555.

    I do not get an error message for the following:

    I am working with git [ 49099e78... ].
    int main()
    {
    int a[2][2];
    a[0][0] = 0;
    //Two problems. stemming from
    // missing shift : Should be a[0][ (3&2) >> 1]
    // 1) we are out of bounds on this axis (but in bounds in the array)
    // 2) value is uninitialised
    return a[0][(3&2)];
    }

    Is there a ticket for this problem?

     

    Last edit: AnotherUser 2015-03-13
  • Daniel Marjamäki

    we are out of bounds on this axis (but in bounds in the array)

    we intentionally don't warn for this. however I agree it's suspicious.

    2) value is uninitialised

    yes the checker doesn't track individual array elements currently. if one element is initialized the checker assumes that the array is initialized.

    I'd say these tickets are related: #3540 #4441 #4527

    I think fixing those is a good start and we can worry about multidimensional arrays if that is still a problem later.

     

    Last edit: Daniel Marjamäki 2015-03-14

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.