On x86-64, I’m curious if there is any mechanism (likely not portable) that would allow the following
int* a = /* ??? */;
assert(a[0] == 0);
a[0] = 100;
assert(a[0] == 0); // Reads of a[0] still return 0
For example, I can imagine a hypothetical hardware device that exposes a range of memory that always yields 0 when the CPU reads from those addresses, and ignores all writes to such addresses. Does x86-64 happen to provide such a pseudo devise that is exposed via mmap, or any other mechanism?