@tster said:
@fist-poster said:(I'm not sure, but is pointer arithmetics guaranteed to give defined results in C and C++, if used with non-sequential memory?)
yes.
No. Why do people answer questions about the language standard without reading the language standard?
The result of pointer arithmetic outside a single object is undefined. Using the result causes undefined behavior.
And there are conforming C implementations where these tricks don't work. Which is fine, since they serve no useful purpose in general-purpose computing. They may be useful in resource-constrained embedded environments, but there implementation-specific code is fine.
It might be worth noting that the problem that started this thread can trivially be fixed by putting a dummy node at the head of the queue, but of course that has the disadvantage of preserving that ghastly design.