This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: malloc attributes and realloc
- From: Jeff Sturm <jsturm at one-point dot com>
- To: Robert Dewar <dewar at gnat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 1 Jan 2004 21:25:06 -0500 (EST)
- Subject: Re: malloc attributes and realloc
On Thu, 1 Jan 2004, Robert Dewar wrote:
> > Nevertheless, the comment isn't quite right, isn't it? I was thinking of
> > the example "p1=malloc(n);free(p1);p2=malloc(n)" in which p1 == p2 is
> > possible even though they do not alias.
>
> But after the free, p1 has an undefined value, and indeed the comparison
> p1==p2 is undefined at that point, so it is certainly not something the
> compiler has to worry about.
Yes. I realized too late that this was a language lawyer question.
I rather like the idea of warning in this situation, as Daniel mentioned.
Jeff