This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC][PATCH v2] Add reallocarray function.
- From: Rich Felker <dalias at libc dot org>
- To: Paul Eggert <eggert at cs dot ucla dot edu>
- Cc: Andreas Schwab <schwab at suse dot de>, libc-alpha at sourceware dot org
- Date: Tue, 20 May 2014 13:01:26 -0400
- Subject: Re: [RFC][PATCH v2] Add reallocarray function.
- Authentication-results: sourceware.org; auth=none
- References: <5379208F dot 8030000 at cs dot ucla dot edu> <2080621 dot 6fAB4UMNoY at descartes> <Pine dot LNX dot 4 dot 64 dot 1405191501120 dot 25418 at digraph dot polyomino dot org dot uk> <20140520020108 dot GV507 at brightrain dot aerifal dot cx> <mvm61l0rhj3 dot fsf at hawking dot suse dot de> <537B7849 dot 1010208 at cs dot ucla dot edu>
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