This is the mail archive of the
mailing list for the GCC project.
Re: malloc attributes and realloc
Gabriel Dos Reis wrote:
email@example.com (Robert Dewar) writes:
Not really. As Joseph pointed out earlier, if you save the pointer
value in an array of unsigned char and latter do bits compare, you can
safely determine whether realloc returns the same pointer or not.
Are you sure? Interestingly this one interpretation would make garbage
collection in C impossible, are you sure that is the intent? Why?
Because you could not distinguish between realloc returning the same
pointer, and a different pointer which is then moved so that it looks
the same as the old no longer valid pointer.
There are of course other things in C that make garbage collection
problematic, but this is one of the few ones that does not involve
some kind of pointer punning, at least as far as I can see.
Do you know of others? (cases where no pointer punning is involved,
and the semantics prohibit compacting garbage collection?)