This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: malloc attributes and realloc


> The pointers returned by an __attribute__ (malloc) function are not
> considered distinct, see the pointer comparison example in the foobar
> function below.

>  aaaa = myalloc_withattribute (SZ*sizeof(int));
>  bbbb = myalloc_withattribute (SZ*sizeof(int));
>
>   /* this is not resolved at compile time at this time */
>   if (aaaa == bbbb)
>     return link_error ();

Malloc can always return a null pointer.  Thus the transformation you're
looking for is not valid.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/



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