From mboxrd@z Thu Jan 1 00:00:00 1970 From: mark@codesourcery.com To: davem@redhat.com Cc: chip@perlsupport.com, egcs@egcs.cygnus.com, torvalds@transmeta.com Subject: Re: Linux and aliasing? Date: Wed, 30 Jun 1999 15:43:00 -0000 Message-ID: <19990603120733J.mitchell@codesourcery.com> References: <19990603131344.W375@perlsupport.com> <19990603104038Z.mitchell@codesourcery.com> <199906031824.LAA26672@pizda.davem.net> X-SW-Source: 1999-06n/msg00091.html Message-ID: <19990630154300.L7nCfZgHoEicOVzSZ1NPEB3ObAShcZU4rd2SF4LrlBc@z> >>>>> "David" == David S Miller writes: David> Actually, I've changed my mind. OK, sorry to misrepresent your position. 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. You can turn off the optimization. Then, however, if you complain that the kernel would go faster if type-based alias analysis is in use, you're out of luck. But, this is no worse off than you were before the optimization existed, and Linux worked pretty well in those days too. Despite what you say, you could just use some unions. IMO, it wouldn't take that much to fix up the TCP_IPV4_MATCH macro. I'm sorry the socket structure would become uglier, but, on the other hand, it would make more obvious what exactly it is. Right now, some of the fields in the structure definition are really acting as unions, and you're not making that clear to the reader of the code. David> You know exactly what I'm doing there, and so do I, why David> can't egcs figure it out that easily as well? Good question, but you know very well that it's rhetorical. :-) There are lots of situations where it's obvious what should happen to the programmer, but highly non-trivial to do in the compiler, if possible at all. I agree that in this case a special hack that says "if the access is through the address of a variable/field of one type, but cast to another type, then the user is doing something fishy, and we should treat the access as if it were done with char*" is not ridiculous, and not impossible to implement. You might consider implementing this, or hiring someone else to do it for you. -- Mark Mitchell mark@codesourcery.com CodeSourcery, LLC http://www.codesourcery.com