News for hackers. Stuff that matters.
Re:Re: C as used/implemented in practice by sklogic on Tuesday July 14, 2015 @05:20AM (#9883653)
> I need to have uint8_t* pointers into the middle of buffers which I can then typecast into byte-aligned structs.

Quite a lot of CPUs would just trap here. Assuming that unaligned access is allowed is a sin.

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.
Re:Re: C as used/implemented in practice by Nursie on Tuesday July 14, 2015 @05:47AM (#9883754)
Really?

Because this is very common practice in device or network code, in my experience.

Re:Re: C as used/implemented in practice by sklogic on Tuesday July 14, 2015 @06:07AM (#9883822)
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.