Chris Angelico <ros...@gmail.com> Wrote in message:
> On Sun, Mar 2, 2014 at 3:02 PM, Dave Angel <da...@davea.name> wrote:
>> The quote you make from the C standard doesn't mention malloc,  so
>>  you're arguing different things. It's not the compiler that casts
>>  the malloc return value to the struct type.
>>
>> C++ does implicitly convert the result,  and the return value of
>>  new already has the struct type. But the runtime stores at least
>>  two kinds of overhead on occasion,  the array size, and the
>>  vtable. So the malloc address can not be assumed to match the
>>  struct beginning.  (Not even considering that one can override
> 
> Whatever pointer malloc returns is the beginning of the *usable*
> space. Any overhead for array size etc has to be before that; a
> virtual function table pointer would be inside that space, but that's
> very much compiler-dependent.
> 

Sure,  for some definition of "usable".  Overhead such as block
 size, freelist pointer etc., are obviously outside of the
 returned block.  But the array size that's specified in a call to
 new [], and the vptr, are definitely inside the malloc'ed block,
 and may be before the struct data.

-- 
DaveA

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to