Re: [Jack-Devel] Alignment (again)
On Thu, Aug 4, 2011 at 1:18 AM, Clemens Ladisch <[hidden]> wrote:
> Gabriel Beddingfield wrote:
>> I ran into a strange bug where the conclusion was that:
>>
>> float *buf = malloc(512*sizeof(float));
>>
>> Is invalid/undefined code. I don't have a copy of the C spec, but the
>> C++ spec says, that since a `float` must be 4-byte aligned... so must a
>> `float*`.[1] However, malloc(3) has no alignment requirements.
>
> C99 7.20.3 says:
> | The pointer returned ... is suitably aligned so that it may be
> | assigned to a pointer to any type of object and then used to access
> | such an object or an array of such objects in the space allocated ...
>
> Anything else would not make sense.
Thanks, Clemons.
This entire thread is invalid. I'm sorry for the noise. Thanks to
all (including Nedko) who set me straight. I take back everything
I've said.
-gabriel
1312470460.17762_0.ltw:2,a <CAPbw_hw2e9N1fgAZ4gPqeX3=jhfJo9efn5GELGiJqbA4myZ3PA at mail dot gmail dot com>