Patch: malloc function attribute
Jeffrey A Law
law@cygnus.com
Mon Nov 29 23:39:00 GMT 1999
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
More information about the Gcc-patches
mailing list