Re:Re: C as used/implemented in practice
by bluetomcat on Tuesday July 14, 2015 @06:33AM
(#9883890)
> Quite a lot of CPUs would just trap here
Or even worse -- for example, ARM CPUs usually round-down the misaligned address to the closest boundary when alignment checking is disabled. This means that attempting to access a 4-byte int at location 11 will silently let the CPU access it at location 8. This can manifest in some very nasty bugs.
Re:Re: C as used/implemented in practice
by stephencanon on Tuesday July 14, 2015 @07:48AM
(#9884120)
IIRC this behavior went away in ARMv6.
Really?
Because this is very common practice in device or network code, in my experience.
Yes, it is a very common crap indeed. I had a lot of pain porting some Linux filesystems to Sparc, for example (had to give up back then, that code was beyond any hope).
Not to mention the endianess issues, an often sight in the crappy networking code.
Quite a lot of CPUs would just trap here. Assuming that unaligned access is allowed is a sin.