]> gcc.gnu.org Git - gcc.git/commitdiff
re PR other/56955 (documentation for attribute malloc contradicts itself)
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 23 May 2014 10:11:03 +0000 (10:11 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 23 May 2014 10:11:03 +0000 (10:11 +0000)
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.

From-SVN: r210848

gcc/ChangeLog
gcc/doc/extend.texi

index bada331694165340c11fa8533a19fa7ca9256a12..aedf2d0a099f1afc8b5d1ed75dc273ddccac8515 100644 (file)
@@ -1,3 +1,10 @@
+2014-05-23  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-23  Maxim Kuvyrkov  <maxim.kuvyrkov@linaro.org>
 
        Fix bootstrap error on ia64
index 28eb8aefa0a5f6e381571f6b778e8946a89d99b7..c54ed6785d609333578c983a1058cea1ff3bab22 100644 (file)
@@ -3207,14 +3207,16 @@ efficient @code{jal} instruction.
 
 @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
This page took 0.087878 seconds and 5 git commands to generate.