Re:Pointers Are Complicated, or What’s in a Byte?
by vardump on Wednesday July 25, 2018 @01:52PM
(#17611264)
> However, given how low-level a language C++ is, we can actually break this assumption by setting i to y-x. Since &x[i] is the same as x+i, this means we are actually writing 23 to &y[0].
> This assumes that the address space of y starts at the end of the address space of x?
No it does not. Any value of x or y should "work", because y-x computes a difference between pointers.
> Could these two allocated blocks of memory ever not be continuous?
Probability they're not continuous is high and only gets higher as the heap gets more fragmented over time.
This assumes that the address space of y starts at the end of the address space of x? In other words x+8==y? Could these two allocated blocks of memory ever not be continuous?