<div dir="ltr"><div>I'm tryin to using clang static analyzer tool for array bound checking but it seems fail , Here is an example : <br></div><div><br></div><div>#include <iostream> <br></div><div><br></div><div>int main() {</div><div>int size;</div><div>std::cin >> size;</div><div><br></div><div>int array[size];</div><div><br></div><div>for(int i = 0 ; i < n ; i++){</div><div>std::cin>>array[i] ;<br></div><div>}</div><div><br></div><div>int test[20] = {9,6,8,9,0,4,5,,3,2,7,8,9,8,12,34,87,43,65,32,23} ; // Just for testing <br></div><div>for(int i = 0 ; i < size; i++){</div><div>std::cout << test[array[i]] << " " ;<br></div><div>}</div><div><br></div><div>return 0;<br></div><div>}</div><div><br></div><div>There is a bug in this program that we are using the value of "array" as an index for the "test array"  , the value of "array" depends on the user and it's very obvious that the user might enter the negative value . When I used the clang static analyzer (--analyze) , it's not able to catch this and I didn't find any CSA checker for array bounds bug on the site . I also tried using the undefined behavior array bound checker for it , it's working when the user enters any negative value otherwise it was quite af . To be honest I didn't expect that this bug would be caught by UBsanitizer . But I was expecting this with clang static analyzer which seems to fail . <br></div><div><br></div><div>Sorry , If any tool exists for this which I wasn't aware of .  Le'me know if there is any tool that exists for this . <br></div><div><br></div><div>Thank you .<br></div></div>