Linux and aliasing?
Wed Jun 30 15:43:00 GMT 1999
On Sun, 6 Jun 1999, Ross Harvey wrote:
> Why? Because it's illegal for a reason, and the alpha platform I support
> has alignment requirements for which I have a guarantee that the memcpy
> approach will work and be reasonably efficient. The cast can generate a
> kernel alignment fault and will either panic or have a hideous run-time
> fixup cost.
Indeed. Which is why we have "get_unaligned()" for example - which does
what the name suggests. Exactly because memcpy() is _not_ acceptable for a
fairly obvious syntactic reason.
I certainly would not knowingly ever apply a patch that adds memcpy's like
in the example. They may exist in drivers where I don't care what stupid
things people do, but it's not something I consider acceptable coding
practice for any regular stuff.
I'd be pretty impressed if gcc _were_ able to generate the correct code
for the example specified - that would be fairly impressive in itself.
Currently that's not the case. And if I were a compiler guy, I'd try my
best to encourage people to use other constructs and making sure they work
More information about the Gcc