4 ms·
if you're adding 1 to a pointer, why would you expect it to be equal? I would not expect it to be equal.
by _RPM 8y ago
if you're adding 1 to a pointer, why would you expect it to be equal? I would not expect it to be equal.
- armitron 8y agoHe's adding "1" to the pointer that points to the variable "b" which in this case is allocated immediately below "a" in the stack. Thus adding one will make the two pointers equal.
- saagarjha 8y agoThe layout of things on the stack is completely implementation-defined.
- sannee 8y agoIt has been a while since I read the standard, but this seems well into the realm of undefined behavior, not implementation defined.
- saagarjha 8y agoFrom my understanding, how the stack is laid out is implementation-defined; attempting to actually observe this ordering in your program is undefined behavior.