This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: malloc attributes and realloc
- From: dewar at gnat dot com (Robert Dewar)
- To: drow at mvista dot com, gdr at integrable-solutions dot net
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 1 Jan 2004 18:40:55 -0500 (EST)
- Subject: Re: malloc attributes and realloc
> And it is not clear that you can conclude from this that the behaviour
> is undefined. If realloc returns a pointer that is equal to its
> argument, it is clear that the storage is guranteed to be reserved for
> the object pointed to. But if it does return a different value, then
> the behaviour becomes undefined. That is, I think, what Joseph was
> alluding to with his "bits compare".
But if there are two non-determistic possibilities, then a program
that counts on one of the two possibilities is incorrect anyway, so
the fact that something *might* be undefined means semantically that
it *is* undefined.
The interesting question to ask is whether a compiler can use this
fact even though it knows that in its particular implementation only
one of the two possibilities will be chosen. I think the answer to
this must be yes, or you get into a semantic mess.