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

--- Comment #5 from kargls at comcast dot net ---
(In reply to Jerry DeLisle from comment #4)
> Confirmed, my first question, is the code valid? I need to think about it. I
> dont know why not.

F2023, 10.2.1.2 Intrinsic assignment statement, page 189

   If the variable is a pointer, it shall be associated with a definable
   target such that the type, type parameters, and shape of the target and
   expr conform.

program test_crash
    use autodiff_mre
    implicit none
    type(ad_node), pointer :: n1
    n1 = ad_init_func(7.0)
end program test_crash

n1 is a pointer.  It is not associated with with a definable target.

If one allocates n1 in test_crash, then the code works, ie., 

program test_crash
    use autodiff_mre
    implicit none
    type(ad_node), pointer :: n1
    allocate(n1)            ! pointer associated with anonymous memory.
    n1 = ad_init_func(7.0)  ! this likely leaks memory
end program test_crash

Reply via email to