News for hackers. Stuff that matters.
Re:The Byte Order Fiasco by nly on Saturday May 08, 2021 @10:47AM (#27087600)
I agree then that in Rust you could make something consistent.

I think there's no need for explicit shifts. You need to memcpy anyway to deal with alignment issues, so you may as well just copy in to the last 3 bytes of a zero-initialized, big endian, 32bit uint.

https://gcc.godbolt.org/z/jEnsW8WfE

Re:The Byte Order Fiasco by raphlinus on Saturday May 08, 2021 @11:29AM (#27088009)
That's just constant folding. Here's what it looks like when you actually need to go to memory:

https://gcc.godbolt.org/z/9qGqh6M1E

And I think we're on the same page, it should be possible to get similar results in Rust.