[Pitch] Unaligned Loads and Stores from Raw Memory

Source compatibility means all existing code has to work when compiled against a newer standard library. It does not mean all new code has to work when compiled against an older standard library.

I'm in favor of this variant of the proposal (and a possible loadAligned when performance is key) because of the principle that the default thing should be correct. Yes, we're already in UnsafePointer territory; yes, there's still the huge pitfall of bindMemory; but I still think it'd be a better user experience to get slower but always valid loads by default.

That said, binary compatibility may prove to be a limiting factor here: on Apple platforms, code compiled with Swift 5.6 must run with an old implementation of UnsafeRawPointer.load back to Swift 5.0. I suspect it'd be safe because a non-inlined version of the code would be generic, and therefore already using something like memcpy, but someone would have to verify.

4 Likes