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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tkoenig at gcc dot gnu.org

--- Comment #8 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
(In reply to anlauf from comment #7)
> 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.

Sounds like a good solution to me.

Reply via email to