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

Jean Lee xiaoyur347 at gmail.com
Sun Oct 20 00:35:48 PDT 2013


#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);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131020/474e5987/attachment.html>


More information about the cfe-dev mailing list