public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>
To: jakub@redhat.com
Cc: libc-hacker@sources.redhat.com
Subject: Re: [PATCH] Fix realloc prototype (BZ #4792)
Date: Mon, 16 Jul 2007 10:30:00 -0000	[thread overview]
Message-ID: <20070716102947.24376.qmail@md.dent.med.uni-muenchen.de> (raw)
In-Reply-To: <20070716100214.GP4603@sunsite.mff.cuni.cz> (message from Jakub Jelinek on Mon, 16 Jul 2007 12:02:14 +0200)

Hi,

> info gcc says on the malloc attribute:
> `malloc'
>      The `malloc' attribute is used to tell the compiler that a function
>      may be treated as if any non-`NULL' pointer it returns cannot
>      alias any other pointer valid when the function returns.  This
>      will often improve optimization.  Standard functions with this
>      property include `malloc' and `calloc'.  `realloc'-like functions
>      have this property as long as the old pointer is never referred to
>      (including comparing it to the new pointer) after the function
>      returns a non-`NULL' value.

That text is IMHO completely correct and adequate.  But note that the
last sentence after "as long as" refers to a case that is _undefined_
by the C standard for the realloc function.  If realloc returns
non-NULL, the "old pointer" must not be used any more, it is just as
if free() had been called on it.  In other words, our "realloc" in
libc is not just "realloc-like" but it is _the_ C realloc.

> 2007-07-16  Jakub Jelinek  <jakub@redhat.com>
> 
> 	[BZ #4792]
> 	* stdlib/stdlib.h (realloc): Remove __attribute_malloc__.
> 	* malloc/malloc.h (realloc): Likewise.

Based on the argument above, I disagree with this change.

Within gcc, I guess you are referring to:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32748

But maybe that is an internal "realloc-like" function were comparison
with the old pointer is intended and useful?  For libc, did you have a
particular issue/bug in mind beyond general principles?

Regards,
Wolfram.

  reply	other threads:[~2007-07-16 10:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-16  9:58 Jakub Jelinek
2007-07-16 10:30 ` Wolfram Gloger [this message]
2007-07-16 11:15   ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070716102947.24376.qmail@md.dent.med.uni-muenchen.de \
    --to=wmglo@dent.med.uni-muenchen.de \
    --cc=jakub@redhat.com \
    --cc=libc-hacker@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).