> I feel like dereferencing an incorrectly aligned pointer could be a runtime error
By checking the alignment on every access? That'd be far too expensive if the machine you're on doesn't trap.
By checking the alignment on every access? That'd be far too expensive if the machine you're on doesn't trap.
Yeah, but good luck selling that... for the reasons you've identified it'd be a nightmare to run C on it.
Editing here because it looks like we've hit the max reply depth. This wouldn't be like UB in the same way that code that could generate an out-of-bounds memory accesses is not UB. The critical thing is that the compiler should assume that the hardware error does not occur.