]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fortran: Remove default initialization of local pointers's span
authorMikael Morin <morin-mikael@orange.fr>
Tue, 5 Aug 2025 12:58:00 +0000 (14:58 +0200)
committerMikael Morin <mikael@gcc.gnu.org>
Tue, 5 Aug 2025 20:35:07 +0000 (22:35 +0200)
A pointer has no default initialization; it is invalid to use it before
it is associated to a target.  We can just as well leave its span field
uninitialized, and wait for the first pointer association to define a
span value.  The value of zero was an invalid span value anyway.

gcc/fortran/ChangeLog:

* trans-decl.cc (gfc_trans_deferred_vars): Don't default
initialize the span of local pointer arrays.

gcc/fortran/trans-decl.cc

index b495f43bbeae6d0554df32068bbf14ee8356d9d9..8992dbcf23bdaf4cbf482d88199ab8d65f67a655 100644 (file)
@@ -4936,20 +4936,6 @@ gfc_trans_deferred_vars (gfc_symbol * proc_sym, gfc_wrapped_block * block)
            }
        }
 
-      if (sym->attr.pointer && sym->attr.dimension
-         && sym->attr.save == SAVE_NONE
-         && !sym->attr.use_assoc
-         && !sym->attr.host_assoc
-         && !sym->attr.dummy
-         && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (sym->backend_decl)))
-       {
-         gfc_init_block (&tmpblock);
-         gfc_conv_descriptor_span_set (&tmpblock, sym->backend_decl,
-                               build_int_cst (gfc_array_index_type, 0));
-         gfc_add_init_cleanup (block, gfc_finish_block (&tmpblock),
-                               NULL_TREE);
-       }
-
       if (sym->ts.type == BT_CLASS
          && (sym->attr.save || flag_max_stack_var_size == 0)
          && CLASS_DATA (sym)->attr.allocatable)