This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: malloc function attribute



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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]