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

--- Comment #3 from anlauf at gcc dot gnu.org ---
(In reply to Paul Thomas from comment #2)
> For whatever reason, the chunk in gfc_conv_intrinsic_size doesn't quite work
> correctly because the wrong message is selected. Thus a bit more work is
> required....

Playing around with reduced testcases shows that the origin might be
rather obscure.  The following case does not generate any runtime error
with -fcheck=pointer:

module m
  type t
  end type
contains
  function f(x) result(z)
    integer  :: x(:)
    type(t)  :: z(size(x))
  end
  subroutine s
    integer               :: a(2)
    class(t), allocatable :: c(:)
    c = f(a)
  end
end

while replacing the type of dummy x in f to class(*):

module m
  type t
  end type
contains
  function f(x) result(z)
    class(*) :: x(:)
    type(t)  :: z(size(x))
  end
  subroutine s
    integer               :: a(2)
    class(t), allocatable :: c(:)
    c = f(a)
  end
end

now has in the dump tree within the caller s:

  _gfortran_runtime_error_at (&"At line 7 of file pr99112-z3.f90"[1]{lb: 1 sz:
1}, &"Pointer argument \'x\' is not associated"[1]{lb: 1 sz: 1});

Reply via email to