[cfe-dev] Static analyzer

Ted Kremenek kremenek at apple.com
Mon Jul 7 13:44:28 PDT 2008


On Jul 7, 2008, at 1:38 PM, Nico Weber wrote:

>>>
>>> 2. The project I'm checking contains several sections that look like
>>> this:
>>>
>>>   const void *bytes = [data bytes];
>>>   int rows = *((int*)bytes); bytes += sizeof(int);
>>>
>>> scan_build complains in these cases that "Value stored to 'bytes' is
>>> never read".
>>
>> I mocked up a test case, but I couldn't really reproduce this  
>> error.  If it is no trouble, can you file a Bugzilla report with a  
>> reduced test case that exhibits the problem?  Filing a Bugzilla  
>> report also ensures that a fix eventually goes in, as requests for  
>> changes have started queuing up and I don't want to forget this one.
>
> Done: http://llvm.org/bugs/show_bug.cgi?id=2528

Thanks for filing the bug report.  My belief is that the checker is  
doing the right thing.  The warning has to do with the "+=" operation  
to bytes, not the store to rows.  The "+=" increment is essentially:

    bytes = bytes + sizeof(int);

The checker is saying that the new value stored to bytes is never used  
(and in your test case, it isn't).

Could it be the case that the test case doesn't capture the issues  
that you are seeing?

Ted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080707/8b12fe0f/attachment.html>


More information about the cfe-dev mailing list