#define M 2structKey{intsts;};typedefstructKeykeytype;typedefstructpage{keytypekey[2*M];}*pageptr;pageptrNewPage();voidBkSplit(pageptrp,intk){intj,m;pageptrq;if(k<=M){m=M;}else{m=M+1;}q=Newpage();for(j=m+1;j<=2*M;j++){q->key[j-m-1]=p->key[j-1];}}
When I run cppcheck, It outputs below error:
[C:/Users/xxxx/Desktop/cppcheck.c:27] (error) Array 'q->key[4]' accessed at index -1, which is out of bounds. [negativeIndex]
I can sure there is no 'index out of bounds.
How to solve this problem?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Below is a simple code:
When I run cppcheck, It outputs below error:
I can sure there is no 'index out of bounds.
How to solve this problem?
Thanks for reporting this false positive. Ticket is here: https://trac.cppcheck.net/ticket/11844