This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Can realloc be marked as a mallloc-like function?

This patch

causes the regression:

The only relevant change is

Index: gcc/fortran/trans-decl.c
--- gcc/fortran/trans-decl.c	(revision 126214)
+++ gcc/fortran/trans-decl.c	(working copy)
@@ -2276,6 +2276,7 @@ gfc_build_builtin_function_decls (void)
 				     pvoid_type_node, 2, pvoid_type_node,
+  DECL_IS_MALLOC (gfor_fndecl_internal_realloc) = 1;
   gfor_fndecl_allocate =
     gfc_build_library_function_decl (get_identifier (PREFIX("allocate")),

In calls.c, there are comments:

          /* The return value from a malloc-like function can not alias
             anything else.  */

It looks like gcc assumes a functon marked with DECL_IS_MALLOC won't
return an address which can alias something else. But it isn't true
for realloc. Now, the qestions are

1. Can gcc make such an assumption?
2. Can realloc be marked as DECL_IS_MALLOC.

BTW, glibc also marks realloc with __attribute_malloc__.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]