[Bug fortran/51073] _gfortran_caf_register incorrectly assumes malloc(0) returns non-NULL
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Nov 10 11:10:00 GMT 2011
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));
More information about the Gcc-bugs
mailing list