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: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: libc-alpha at sourceware dot org
- Date: Tue, 20 May 2014 08:44:09 -0700
- 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>
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