This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: malloc function attribute
- To: Mark Mitchell <mark at codesourcery dot com>
- Subject: Re: Patch: malloc function attribute
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Tue, 30 Nov 1999 00:35:41 -0700
- cc: ghazi at caip dot rutgers dot edu, green at cygnus dot com, gcc-patches at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <19991129074845D.mitchell@codesourcery.com>you write:
> I believe that if you know something about your realloc
> implementation, then you can know that realloc will return the same
> pointer. So, I can imagine something like:
>
> int *ip = (int *) malloc (8);
> int *ip2 = (int* ) realloc (ip, 16);
>
> and that the programmer knows that `ip' and `ip2' *are* aliases. I've
> just looked at the C standard and I don't see any reason to believe
> that using `ip' in this code yields undefined behavior,
Egad. I'll accept this. I don't have anything to counter it. With this
in mind we need to not consider realloc or xrealloc as being malloc-like.
Bummer.
> Maybe I'm off base, but I thought that the malloc attribute said the
> new pointer doesn't alias anything.
You're correct.
jeff