This is the mail archive of the gcc-bugs@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]

[Bug other/56955] documentation for attribute malloc contradicts itself


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56955

--- Comment #16 from Richard Biener <rguenth at gcc dot gnu.org> ---
One reason for why realloc is "hard" is that there is no language that says
it is undefined to access the object via the old pointer, but there is only
language that says the old and the new pointer values may be equal.  Thus,

void foo (int *p)
{
  int *q = realloc (p, sizeof (int));
  *q = 2;
}

may I remove the store *q = 2 as dead?  The new pointer doesn't escape
and thus nothing can read from it ...


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