This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: malloc function attribute
- To: gcc-patches at gcc dot gnu dot org
- Subject: Re: Patch: malloc function attribute
- From: Per Bothner <per at bothner dot com>
- Date: 30 Nov 1999 00:00:44 -0800
- References: <28481.943947341@upchuck>
In message <19991129074845D.mitchell@codesourcery.com>you write:
> Maybe I'm off base, but I thought that the malloc attribute said the
> new pointer doesn't alias anything.
I'm not convinced. From the point of view of the spec,
after a call to realloc, the orginal pointer is undefined.
I don't think there is anything useful to be gained by
thinking of realloc as other than an optimization/convenience hack
for malloc+copy+free. Hence after realloc returns, it is
arguably safe for the compiler to assume that the result is not
aliased with anything else, since if it is, it is "accidental",
and the programmer cannot use that fact.
Just my opinion; since I don't know what the compiler does
with the malloc atribute, it is not a very informed opinion.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/