[cfe-commits] r86504 - in /cfe/trunk: lib/Analysis/CheckSizeofPointer.cpp test/Analysis/sizeofpointer.c

Ted Kremenek kremenek at apple.com
Mon Nov 9 17:50:25 PST 2009


On Nov 9, 2009, at 4:20 PM, Zhongxing Xu wrote:

> 2009/11/10 Ted Kremenek <kremenek at apple.com>:
>> Hi Zhongxing,
>>
>> I think the previous wording was more in the right direction as it  
>> explained
>> the actual problem; "This can produce an unexpected result." is  
>> fairly
>> content-free unless you already know what the warning is about.
>>
>> How about:
>>
>>  "Call to sizeof() returns the size of the pointer (X bytes)  
>> instead of how
>> much memory has been allocated by malloc()"
>
> I think sizeof() never return the memory allocated by malloc(). (CWE
> is misleading) sizeof only returns the size of the object represented
> by the expression.

Right.  I think the CWE is inspired by people taking the sizeof an  
array or some buffer and think that it's getting the actual size.   
That fact that it gets the sizeof the pointer is what confuses many  
people.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20091109/ad6079d0/attachment.html>


More information about the cfe-commits mailing list