Linux and aliasing?

David S. Miller davem@redhat.com
Thu Jun 3 12:25:00 GMT 1999


   From: mark@codesourcery.com
   Date: Thu, 03 Jun 1999 12:07:33 -0700

       David> I'm not saying this should be the normal mode of operation,
       David> but some mechanism needs to exist so that such code can be
       David> made valid _without_ resorting to ugly unions.

   There is one: -fno-strict-aliasing.  

And there is another: if my code is not "standard C" then output an
error instead of silently generating bad code.  Then again, I did not
specify -ansi and -ansi is not the default, and therefore I have not
asked for "standard C", instead I expect to get "GNU C" which
traditionally has been "standard C + common sense" :-)

So in that light, there is:

	If some pointer is cast to another of a different storage
	class or size, I'm doing something strange, and the compiler
	should turn off aliasing optimizations for anything to do with
	that set/class of pointers.

I know it can be detected, and I also know aliasing can be turned off
for a particular class of related pointers just as easily in the
current compiler code.

Common sense should override whatever standards say, where feasible,
and I argue that here it is indeed feasible.

	You might consider implementing this, or hiring someone else
	to do it for you.

Before anyone considers implementing any change, it would be prudent
to make sure most folks agree on the issue and how it should be
solved.

Later,
David S. Miller
davem@redhat.com


More information about the Gcc mailing list