]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/53521 (Memory leak with zero-sized array constructor)
authorTobias Burnus <burnus@net-b.de>
Fri, 1 Jun 2012 20:40:36 +0000 (22:40 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Fri, 1 Jun 2012 20:40:36 +0000 (22:40 +0200)
2012-06-01  Tobias Burnus  <burnus@net-b.de>

        PR fortran/53521
        * trans.c (gfc_deallocate_scalar_with_status): Properly
        handle the case size == 0.

From-SVN: r188125

gcc/fortran/ChangeLog
gcc/fortran/trans.c

index 9271062ecf508b060fec13e246923bc6f75d821e..6807f7f1f78b3124f2131f119e512ddc2f668935 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-01  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/53521
+       * trans.c (gfc_deallocate_scalar_with_status): Properly
+       handle the case size == 0.
+
 2012-03-06  Tobias Burnus  <burnus@net-b.de>
 
        Backport from mainline
index 6ce25543c85926ea84d698be370da7602439bb7d..3f41bf2faf1127320a772c283d59290c7461c88f 100644 (file)
@@ -920,15 +920,12 @@ internal_realloc (void *mem, size_t size)
   if (!res && size != 0)
     _gfortran_os_error ("Out of memory");
 
-  if (size == 0)
-    return NULL;
-
   return res;
 }  */
 tree
 gfc_call_realloc (stmtblock_t * block, tree mem, tree size)
 {
-  tree msg, res, negative, nonzero, zero, null_result, tmp;
+  tree msg, res, negative, nonzero, null_result, tmp;
   tree type = TREE_TYPE (mem);
 
   size = gfc_evaluate_now (size, block);
@@ -969,13 +966,6 @@ gfc_call_realloc (stmtblock_t * block, tree mem, tree size)
                     build_empty_stmt (input_location));
   gfc_add_expr_to_block (block, tmp);
 
-  /* if (size == 0) then the result is NULL.  */
-  tmp = fold_build2 (MODIFY_EXPR, type, res, build_int_cst (type, 0));
-  zero = fold_build1 (TRUTH_NOT_EXPR, boolean_type_node, nonzero);
-  tmp = fold_build3 (COND_EXPR, void_type_node, zero, tmp,
-                    build_empty_stmt (input_location));
-  gfc_add_expr_to_block (block, tmp);
-
   return res;
 }