This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

[Bug fortran/51073] _gfortran_caf_register incorrectly assumes malloc(0) returns non-NULL


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51073

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-11-10 11:02:06 UTC ---
Patch which makes sure that for static coarrays the minimal size is 1.

--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -4234,6 +4238,11 @@ generate_coarray_sym_init (gfc_symbol *sym)

   size = TYPE_SIZE_UNIT (gfc_get_element_type (TREE_TYPE (decl)));

+  /* Ensure that we do not have size=0 for zero-sized arrays.  */
+  size = fold_build2_loc (input_location, MAX_EXPR, size_type_node,
+                         fold_convert (size_type_node, size)
+                         build_int_cst (size_type_node, 1));
+
   if (GFC_TYPE_ARRAY_RANK (TREE_TYPE (decl)))
     {
       tmp = GFC_TYPE_ARRAY_SIZE (TREE_TYPE (decl));


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