[cfe-dev] testing the clang static code analyzer

Lior Brafman liorbr at checkpoint.com
Thu Aug 15 09:16:33 PDT 2013


Hi,

I installed the Clang Static Code Analyzer and tried testing it with a very simple example:
#include <stdio.h>
#include <stdlib.h>

Int main(int ac, char* argv[])
{
                int a;
                char *string;

                string = (char*) malloc(10);
                string[11] = 'X';
                return *(int *)0;
}

I expected 4 errors to be discover:

1.       Unused variable: a

2.       Out of bound access to array string

3.       Memory leak: string

4.       Dereference of null pointer at the return statement

But instead only one error was discovered (error number 4)

Can you please help me figure out why I don't get all the errors?

Thanks,
Lior Brafman
R&D
CheckPoint
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130815/3d150b20/attachment.html>


More information about the cfe-dev mailing list