https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48958

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P5
             Status|SUSPENDED                   |NEW
                 CC|anlauf at gmx dot de               |
          Component|libfortran                  |fortran

--- Comment #7 from anlauf at gcc dot gnu.org ---
The question on what to do with runtime checks and possibly undefined pointers,
which has been repeated by Thomas on the ML, could be solved by initializing
the data component when -fcheck=pointer is specified.

A somewhat hackish solution which regtests cleanly:

diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index b2c39aa32de..6e1f27ead45 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -10668,7 +10668,9 @@ gfc_trans_deferred_array (gfc_symbol * sym,
gfc_wrapped_block * block)
     }

   /* NULLIFY the data pointer, for non-saved allocatables.  */
-  if (GFC_DESCRIPTOR_TYPE_P (type) && !sym->attr.save &&
sym->attr.allocatable)
+  if (GFC_DESCRIPTOR_TYPE_P (type) && !sym->attr.save
+      && (sym->attr.allocatable
+         || (sym->attr.pointer && (gfc_option.rtcheck &
GFC_RTCHECK_POINTER))))
     {
       gfc_conv_descriptor_data_set (&init, descriptor, null_pointer_node);
       if (flag_coarray == GFC_FCOARRAY_LIB && sym->attr.codimension)

Still need to learn weather this is the right solution, but it does the job.

Reply via email to