3 ms·
One of the main consequences of how the abstract machine in the standard is defined is that it does not imply that there is one big flat memory. It requires poi
by dfox 4y ago
One of the main consequences of how the abstract machine in the standard is defined is that it does not imply that there is one big flat memory. It requires pointers into arrays to behave as if there was, but that is it. In other words, taking a ptr_diff_t of two pointers that do not point into the same array is UB (6.5.6.10).
Trivial example of platform where that is relevant is 16b 8086 with anything but tiny memory model (ie. CS=DS=SS). Somewhat more relevant are various Harvard-ish embedded platforms with separate RAM/ROM address spaces. In both cases there are C implementations that are used in production applications.
Another reason for this rule (and probably the original one) are various platforms with segmentation based fine-grained memory protection. That means either things like Burroughs large systems or running C on top of some kind of VM while preserving the underlying memory management. And there are C implementations for that kinds of environments (That most of the existing C code is not directly compatible with that kind of implementation is another thing).
- pjc50 4y agoAnother thing that turns out to be compatible with the C memory model is "doing weird things with pointer bits", such as pointer authentication: https://www.qualcomm.com/content/dam/qcomm-martech/dm-assets/documents/pointer-auth-v7.pdf https://www.qualcomm.com/content/dam/qcomm-martech/dm-assets...