https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99295
Bug ID: 99295 Summary: documentation on __attribute__((malloc)) is wrong Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: roland.illig at gmx dot de Target Milestone: --- https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html says: > (s1) Using the attribute with no arguments is designed to improve > optimization. > (s2) The compiler predicts that a function with the attribute returns > non-null in most cases. > (s3) Functions like malloc and calloc have this property because > they return a pointer to uninitialized or zeroed-out storage. > (s4) However, functions like realloc do not have this property, > as they may return pointers to storage containing pointers to > existing objects. In GCC 4, the text was different and made sense. At some later point, the sentence s2 was rewritten. The sentence s4 still refers to s2, but the "do not have this property" no longer applies. In GCC 4, "this property" was "returns uninitialized memory", while in GCC 11, "this property" is "returns non-NULL in most cases". The documentation should be made coherent again. https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Function-Attributes.html https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html