[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] How serious is GCC "cast increases requiered alignment of target type" warning?



m0n0 wrote:
m68k-atari-mint-gcc -c testm.c -Wall -Wcast-align

You didn't mention that -Wcast-align option !
This is why I never saw your warning, because it is disabled by default.

        return (uint32_t *)(nsfb->ptr + (y * nsfb->linelen) + (x << 2));

I can't compile right now, but now I understand.
If nsfb->ptr is aligned on 4 and nsfb->linelen is a multiple of 4, the
result will always be aligned, since (x << 2) is always a multiple of 4.
However, the compiler can't be sure about that so it generates a warning.
So in this case, if the requirements are met, the returned pointer will
always be valid, and the warning can safely be ignored.

--
Vincent Rivière