[LLVMdev] Reference Manual Clarifications 2

Chris Lattner sabre at nondot.org
Sat Apr 19 15:39:16 PDT 2008


On Apr 19, 2008, at 2:21 PM, Nick Lewycky wrote:

> Chris Lattner wrote:
>> On Apr 1, 2008, at 6:41 PM, Jon Sargeant wrote:
>>> Regarding free, I also think your wording isn't clear enough: "If  
>>> the
>>> pointer is null, the result is undefined."  The free result is void.
>>> Consider rewording as "If the pointer is null, the operation is  
>>> valid
>>> but does not free the pointer."
>>
>> It isn't though.  free(NULL) could segfault the app, for example.
>
> That's not compatible with C free(). From 7.20.3.2/2:
>
> "The free function causes the space pointed to by ptr to be  
> deallocated,
> that is, made available for further allocation. If ptr is a null
> pointer, no action occurs."
>
> For whatever reason, I thought that free of null was a normal no-op  
> in LLVM.

Ah ok.  This seems to also be true in C90, I'll update the dox.

-Chris



More information about the llvm-dev mailing list