|
|
|
|
|
by cbsmith
3464 days ago
|
|
Where is it dereferencing the array? *(&arr + 1) - arr
That translates to taking the address one point past the array and subtracting the address of the array from it. It doesn't actually dereference the location past the end of the array.While: (&arr)[1] - arr
might appear to be doing something different, it actually isn't. |
|
&arr + 1 is a pointer to an array that begins just after the existing array.
* is the dereference operator, so it seems to me that *(&arr + 1) dereferences the pointer to the array, resulting in an array (or a reference to an array), which then decays to a pointer.