Re: Is -fno-strict-aliasing still needed?

From: Helge Hafting (
Date: Tue Feb 11 2003 - 05:24:38 EST

Horst von Brand wrote:
> Art Haas <> said:
> > I ask because I've just built a kernel without using that flag -
> > linus-2.5 BK from this morning, probably missing the 2.5.60 release by
> > a few hours.
> The problem with strict aliasing is that it allows the compiler to assume
> that in:
> void somefunc(int *foo, int *bar)
> foo and bar will _*never*_ point to the same memory area (at the same
> struct, or into the same array, etc). There is no way to check for this in
> the compiler in general (the function and the call might be in different
> files, many functions are being called via pointers, ...).

I though pointers to the same type, such as int *, could alias still.

But pointers to different types, such as int* and short* is assumed
to never clash with strict aliasing. And this bites linux
because it sometimes choose to see "two adjacent shorts as one int" for
performance reasons.

I remember the flag was introduced because some IP or TCP
code do exactly this, and converting it all to unions would
render that code unreadable.

Helge Hafting
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Sat Feb 15 2003 - 22:00:32 EST