[cfe-dev] Does clang static analyzer UndefResultChecker.cpp has false positive?

Anna Zaks ganna at apple.com
Mon Oct 21 08:45:50 PDT 2013


I cannot reproduce this on latest clang (TOT) with or without the alpha checkers.

Also, most of the alpha checkers will have false positives and bugs.

Cheers,
Anna.

On Oct 20, 2013, at 12:57 AM, Jean Lee <xiaoyur347 at gmail.com> wrote:

> My environment:
> LLVM 3.3 + CLANG 3.3
> 
> 
> Build command:
> CHECKER="-enable-checker alpha.unix.Stream -enable-checker alpha.unix.SimpleStream -enable-checker alpha.core.SizeofPtr -enable-checker alpha.unix.cstring.BufferOverlap -enable-checker alpha.security.ArrayBoundV2 -enable-checker alpha.unix.PthreadLock"
> 
> scan-build-3.3 ${CHECKER} g++ static_analyzer.cpp -pthread
> 
> 
> 2013/10/20 Jean Lee <xiaoyur347 at gmail.com>
> #include <stdio.h>
> void FunctionFread(const char* szFile)
> {
> 	FILE *fp = fopen(szFile, "rb");
> 	if (fp == NULL)
> 	{
> 		return;
> 	}
> 	
> 	int ofs[2], len;
> 	int nReadNum = fread( ofs, sizeof(int), 2, fp );
> 
> 	if ( nReadNum != 2 )
> 	{
> 		fclose(fp);
> 		return;
> 	}
> 	
>         // warning: The left operand of '-' is a garbage value
> 	len = ofs[1] - ofs[0];
> 	printf("length=%d\n", len);
> 	fclose(fp);
> }
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131021/1a11426c/attachment.html>


More information about the cfe-dev mailing list