This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: malloc attributes and realloc
- From: Chris Lattner <sabre at nondot dot org>
- To: Dan Nicolaescu <dann at ics dot uci dot edu>
- Cc: Ian Lance Taylor <ian at wasabisystems dot com>,Robert Dewar <dewar at gnat dot com>, <gcc at gcc dot gnu dot org>, <drow at mvista dot com>,Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Date: Sun, 4 Jan 2004 21:48:20 -0600 (CST)
- Subject: 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/