Cast alignment warnings

Julien ÉLIE julien at
Mon Aug 1 21:13:42 UTC 2011

Hi Russ,

>> network.c:611:15: error: cast increases required alignment of target type [-Werror=cast-align]
> I've stopped using -Wcast-align because it seems to only produce these
> false positives in the sort of code I usually work on.  People who use the
> warning paper around it by casting to void * first, which doesn't actually
> fix anything, just hides the issue from the compiler and makes the code
> more complicated.  That's the mark of a useless warning to me.

OK, many thanks for all the explanations in this thread.
So if I understand well, we can remove -Wcast-align from the list of warnings used
during a "make warnings".

We have in timecaf/timehash an unsigned char class that is casted to an unsigned int*
for the sake of sscanf().

    n = sscanf(path, "timecaf-%02x/%02x/%04x.CF", (unsigned int*)&class, &t1, &t2);

I bet it is not a problem either -- because a char is 1-byte aligned, so it can be cast
to any other types, especially a 4-byte aligned int.
Please correct me if I am wrong.

Julien ÉLIE

« Un ami fidèle qui parle très bien votre langue et toutes les
  langues vivantes : le latin, le grec, le celte, etc. » (Astérix)

More information about the inn-workers mailing list