Hacker News new | ask | show | jobs
by Ericson2314 1605 days ago
If struct fields weren't aligned, then safe Rust would be completely and utterly broken. And really obviously so.

This isn't just a matter of things "seeming". It is quite literally an implication of Safe Rust works => field offsets must be aligned. There is no other way for safe Rust to be safe, other than alignment not mattering at all because all accesses are careful to pessimistically not rely on it.

I am sorry, but this hypothesis is just completely outside the Overton Window.

1 comments

The thing is, C has an actual standard and people get bit making the same kinds of assumptions on things not stated. You may very well be right that there's no way this will ever happen, but then it also doesn't appear to be guaranteed. They literally say they make no guarantees about the data layout, but you're assuming there is a guarantee about the data layout :P

Maybe this time it works out, but there's plenty of other cases where things are not so clear cut.