[LLVMdev] Reference Manual Clarifications 2
Chris Lattner
sabre at nondot.org
Sat Apr 19 15:40:14 PDT 2008
On Apr 19, 2008, at 3:27 PM, Jon Sargeant wrote:
>>> Regarding malloc and alloca, I realized that the size is unsigned,
>>> so a
>>> negative value for NumElements is impossible. I suggest replacing
>>> "it
>>> is the number of elements allocated" with "it is the UNSIGNED number
>>> of
>>> elements allocated".
>>
>> I'm not sure why this is more clear.
>
> The semantics of malloc and alloca depend on whether you interpret
> NumElements as a signed or unsigned 32-bit integer. For example, if
> NumElements is 0xffffFFFF, should the instruction fail (because
> allocating a negative number of elements doesn't make sense), or
> should
> the instruction allocate 2^32-1 elements? I don't see any mention of
> whether NumElements is signed or unsigned in the documentation.
How could an element count be treated as negative? It doesn't make
sense to allocate negative elements.
-Chris
More information about the llvm-dev
mailing list