Lets do this!
There appears to be some confusion about how virtual address works.
Same Physical Page and Multiple Virtual Addresses Since p and q are both pointers to the same (non-volatile) type that do not compare equal, it might be possible for C++ to assume that the write to p can be lifted out of the conditional and the program optimized to:
This section has incorrect assumptions:
C++ does not make assumptions about pointers, in fact due to how it treats arrays (as pointers), C++ cannot make assumptions about arrays that Fortran or Cobal can, which is why some matrix operations in C++ are slower than Fortran and Cobal as they cannot benefit from hardware accelerators. That require one to make an unsafe C++ assumption. So no, it will not happen.
A process cannot map multiple virtual addresses to the same physical address.
The OS chooses how things are mapped, and as far as I know it doesn't map things to the same physical address except where it makes sense (shared libraries, which store all of their runtime data in the virtual space of their parent process).
Same Virtual Address Maps to Different Physical Pages for Different "threads"
Threads share the same virtual memory mapping for Data, Code, and Heap sections of your program.
They do map the stack differently, but this isn't an issue you should worry about, as you shouldn't pass pointers to things on the stack between threads. Even if threads shared the same stack space doing so is a bad idea.
If you decide for some strange reason to pass pointers to the stack between processes are using pointers to the stack.
Why?
using pointers to the stack from anything that isn't a child of the function that claimed that stack space. Is generally considered bad practice and the source of some really odd behavior.
You will be so busy dealing with other problems caused by this bad life choice that the minor fact that the stack has different physical addresses between threads is the least of your problems.
What does this mean? Don't use pointers to the stack outside of their stack context. Everything else works as expected.
Yea, you could write an OS that did the bad things you describe... But you would have to decide to do this.