#3 unsigned where signed should be used

closed-fixed
nobody
None
5
2008-01-28
2008-01-18
j--n
No

kalman/ekfilter_impl.hpp, line 650-651:
K_UINT_32 i, j, k, N = P_.nrow();
for (i = N - 2 + BEG; i >= BEG; --i) {

if BEG is 0 (the arrays/matrices are 0 indexed), then the loop would stop when i=-1, but i can not be -1, because it is unsigned.

Discussion

  • j--n

    j--n - 2008-01-18

    Logged In: YES
    user_id=797559
    Originator: YES

    this was my hack:

    K_UINT_32 j, k, N = P_.nrow();
    K_INT_32 i;
    for (i = N - 2 + BEG; i >= (K_INT_32)BEG; --i) {

    note that I had to convert BEG to signed to use the signed version of >=

    I had to make a similar change to line 675/708:
    K_INT_32 j;
    for(j = n - 1 + BEG; j >= (K_INT_32)BEG; --j) {

     
  • Vincent Zalzal

    Vincent Zalzal - 2008-01-28

    Logged In: YES
    user_id=1004895
    Originator: NO

    Thank you for your bug report and patch. I have modified the library and made a new release (1.3) with this change.

     
  • Vincent Zalzal

    Vincent Zalzal - 2008-01-28
    • status: open --> closed-fixed
     

Log in to post a comment.