This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: malloc attributes and realloc
Andreas Schwab wrote:
> This is by no means theoretical only. Think of a segmented
> architecture, where loading an invalid value into a segment register
> generates a trap.
On such an architecture, is it necessary to load that segment register
in order to compare a pointer value? Does that mean that in order to
do a pointer comparison you must first cast with (uintptr_t) or similar?
Even on an segmented architecture it needs to be possible to compare
pointers. If it were not necessary, why would realloc() docs talk about
"(possibly moved) block". If there is no test available for determining
whether or not it has moved, then it must be treated as always having
moved. If you must treat it as always having moved, then there is
little point in discussing "(possibly moved) block" and instead say,
"always treat the address returned as a new allocation, whether it has
actually moved or not" [[otherwise, your friendly compiler may delete
code that references your outdated but bitwise identical pointers]].
What am I missing?