| ▲ | account42 2 hours ago | ||||||||||||||||||||||||||||||||||||||||
Which is totally fine and expected for any decent programmer. Casting pointers is clearly here be dragons territory. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | simonask 2 hours ago | parent [-] | ||||||||||||||||||||||||||||||||||||||||
Many, many programmers come to C (and C++) with a lower-level understanding that actually gets in the way here. They understand that all types "are" just bytes and that all pointers "are" just register-sized integer addresses, because that's how the hardware works and has worked for decades. It's perfectly reasonable to expect any load through `int*` to just load 4 bytes from memory, done and done. They get surprised that it is far from the whole story, and the result is UB. Meanwhile, the actual computers we have been using for decades have no problems actually just loading 4 bytes through any arbitrary pointer with zero overhead. But no. | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||