[RFC][PATCH v2] Add reallocarray function.
Rich Felker
dalias@libc.org
Tue May 20 20:47:00 GMT 2014
On Tue, May 20, 2014 at 08:44:09AM -0700, Paul Eggert wrote:
> Andreas Schwab wrote:
> >Please report that as a gcc bug (it doesn't mark it either).
>
> As far as I can tell this is a bug in GCC's documentation, not in
> its implementation. As I mentioned cryptically in my previous
> message, if FOO has the malloc attribute and you execute 'int **p =
> foo (...);', the malloc attribute means that *P cannot point to
> previously-existing storage (because *P is uninitialized junk).
> That is why the attribute applies to calloc (because *P must be
> null, which also cannot point to previously-existing storage) but
> not to realloc (because *P might be initialized and might point to
> previously-existing storage).
>
> For more about this confusing topic, please see:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56955
What is the issue about "previously-existing storage"? Is the concern
that *new->something might alias new (because new==old happens to be
true and the object contained a pointer to itself or part of itself)
or that *new->something merely can alias other existing memory
(whereas GCC assumes it never can)?
Rich
More information about the Libc-alpha
mailing list