From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16533 invoked by alias); 16 Jul 2007 10:30:07 -0000 Received: (qmail 16517 invoked by uid 22791); 16 Jul 2007 10:30:07 -0000 X-Spam-Check-By: sourceware.org Received: from zep00a03.dent.med.uni-muenchen.de (HELO md.dent.med.uni-muenchen.de) (138.245.179.2) by sourceware.org (qpsmtpd/0.31) with SMTP; Mon, 16 Jul 2007 10:29:51 +0000 Received: (qmail 24377 invoked by uid 211); 16 Jul 2007 10:29:47 -0000 Date: Mon, 16 Jul 2007 10:30:00 -0000 Message-ID: <20070716102947.24376.qmail@md.dent.med.uni-muenchen.de> From: Wolfram Gloger To: jakub@redhat.com CC: libc-hacker@sources.redhat.com In-reply-to: <20070716100214.GP4603@sunsite.mff.cuni.cz> (message from Jakub Jelinek on Mon, 16 Jul 2007 12:02:14 +0200) Subject: Re: [PATCH] Fix realloc prototype (BZ #4792) References: <20070716100214.GP4603@sunsite.mff.cuni.cz> Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2007-07/txt/msg00019.txt.bz2 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 > > [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.