3 ms·
There's nothing in the C standard that I could find that dictates that b[] has to follow directly after a[] in memory. That it works is just happenstance (or a
by spc476 5y ago
There's nothing in the C standard that I could find that dictates that b[] has to follow directly after a[] in memory. That it works is just happenstance (or an implementation detail). The only place were order is maintained are fields in a structure definition.
- xscott 5y agoThere's nothing in that example that assumes they are adjacent. It only assumes they are in the same (flat) address space. Put a gigabyte between them if you want. If I had used `uintptr_t` instead of `ssize_t`, I think it's even compliant as far as wraparound goes. edit: Note I changed the code to use uintptr_t