diff mbox

__attribute__ ((malloc)) doc fix (PR other/56955)

Message ID 537E067C.2000906@cs.ucla.edu
State New
Headers show

Commit Message

Paul Eggert May 22, 2014, 2:15 p.m. UTC
Richard Biener wrote:
> Can you try to clarify the wording (I'm not a native speaker).

Sure.  I've filed a clarified version on PR 56955 and am attaching it 
here for convenience.

Comments

Richard Biener May 23, 2014, 10:11 a.m. UTC | #1
On Thu, May 22, 2014 at 4:15 PM, Paul Eggert <eggert@cs.ucla.edu> wrote:
> Richard Biener wrote:
>>
>> Can you try to clarify the wording (I'm not a native speaker).
>
>
> Sure.  I've filed a clarified version on PR 56955 and am attaching it here
> for convenience.

Thanks, installed.

Richard.
diff mbox

Patch

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 210804)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,10 @@ 
+2014-05-22  Paul Eggert  <eggert@cs.ucla.edu>
+
+	PR other/56955
+	* doc/extend.texi (Function Attributes): Fix  __attribute__ ((malloc))
+	documentation; the old documentation didn't clearly state the
+	constraints on the contents of the pointed-to storage.
+
 2014-05-22  Richard Biener  <rguenther@suse.de>
 
 	* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Handle
Index: gcc/doc/extend.texi
===================================================================
--- gcc/doc/extend.texi	(revision 210804)
+++ gcc/doc/extend.texi	(working copy)
@@ -3207,15 +3207,17 @@ 
 
 @item malloc
 @cindex @code{malloc} attribute
-The @code{malloc} attribute is used to tell the compiler that a function
-may be treated as if any non-@code{NULL} pointer it returns cannot
-alias any other pointer valid when the function returns and that the memory
-has undefined content.
-This often improves optimization.
-Standard functions with this property include @code{malloc} and
-@code{calloc}.  @code{realloc}-like functions do not have this
-property as the memory pointed to does not have undefined content.
+This tells the compiler that a function is @code{malloc}-like, i.e.,
+that the pointer @var{P} returned by the function cannot alias any
+other pointer valid when the function returns, and moreover no
+pointers to valid objects occur in any storage addressed by @var{P}.
 
+Using this attribute can improve optimization.  Functions like
+@code{malloc} and @code{calloc} have this property because they return
+a pointer to uninitialized or zeroed-out storage.  However, functions
+like @code{realloc} do not have this property, as they can return a
+pointer to storage containing pointers.
+
 @item mips16/nomips16
 @cindex @code{mips16} attribute
 @cindex @code{nomips16} attribute