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

Jean Lee xiaoyur347 at gmail.com
Thu Oct 24 18:16:08 PDT 2013


Thank you. I will try to compile clang to see the problem when I have spare
time.

Cheers,
Jean.


2013/10/21 Anna Zaks <ganna at apple.com>

> 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/20131025/95b8c09f/attachment.html>


More information about the cfe-dev mailing list