By: Gabriele Svelto (gabriele.svelto.delete@this.gmail.com), October 30, 2006 7:28 am
Room: Moderated Discussions
JasonB (no@spam.com) on 10/30/06 wrote:
---------------------------
>We typically think of "aligned" to mean "on an address that is a multiple of the
>size of the data type in question", because that is a very common requirement, and
>therefore think of x86 as supporting "unaligned" accesses, but I believe the C standard
>is using "unaligned" to mean "at an address that the CPU doesn't support reading
>a value of that size from". It is simply exposing whatever the CPU supports, which
>is a philosophy of C. This obviously makes it harder to write portable code, but
>easier to write fast and efficient code for a particular platform, which is also a philosophy of C.
Yeah, but what I said wasn't that C didn't support unaligned access. What I said was that you cannot obtain a pointer which respects the strict aliasing rules which is unaligned, i.e. if you have an unaligned pointer then you're breaking the strict aliasing rules and potentially nasty stuff may happen.
Gabriele
---------------------------
>We typically think of "aligned" to mean "on an address that is a multiple of the
>size of the data type in question", because that is a very common requirement, and
>therefore think of x86 as supporting "unaligned" accesses, but I believe the C standard
>is using "unaligned" to mean "at an address that the CPU doesn't support reading
>a value of that size from". It is simply exposing whatever the CPU supports, which
>is a philosophy of C. This obviously makes it harder to write portable code, but
>easier to write fast and efficient code for a particular platform, which is also a philosophy of C.
Yeah, but what I said wasn't that C didn't support unaligned access. What I said was that you cannot obtain a pointer which respects the strict aliasing rules which is unaligned, i.e. if you have an unaligned pointer then you're breaking the strict aliasing rules and potentially nasty stuff may happen.
Gabriele