Cast alignment warnings

Julien ÉLIE julien at trigofacile.com
Sun May 24 09:26:35 UTC 2015


Hi Russ,

>> So if I understand well, do we just need doing the following thing?
>> (It builds fine, without warning.)
>
> Yup, this patch is correct.  (And it looks like you already committed it,
> yay!)

OK, thanks for your confirmation.
I indeed went ahead after having thoroughfully tested the changes 
(rebuilding my history file with makehistory, because it is the tool 
that calls these modified function for articles stored in timehash and 
timecaf methods).



>> I've just come across the following ones:
>
>> buffindexed/buffindexed.c:1051:20: warning: cast from 'char *' to 'GROUPENTRY *'
>>        increases required alignment from 1 to 8 [-Wcast-align]
>>      GROUPentries = (GROUPENTRY *)((char *)GROUPheader + sizeof(GROUPHEADER));
>>                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> I suspect that one could just write this as:
>
>      GROUPentries = (void *) &GROUPheader[1]
>
> given that GROUPheader is already a pointer to a GROUPHEADER.  I wonder if
> that would make the warning go away.  (Does GCC on amd64 produce those
> warnings?  I seem to recall that it doesn't.)

amd64 does not produce those warnings.  I have also just tested with the 
suggested change ((void *) &GROUPheader[1]).
I found them with Clang on Mac OS X.


Should
   ovblock = (OVBLOCK *)((char *)addr + pagefudge);
just be changed to
   ovblock = (void *)((char *)addr + pagefudge);
in buffindexed/buffindexed.c:1667?

It suppresses the warning.

-- 
Julien ÉLIE

« – Vous ramassez des champignons sans les connaître ?
   – Et alors ? Ce n'est pas pour les manger mais pour les vendre. »


More information about the inn-workers mailing list