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

--- Comment #1 from Gerhard Steinmetz <gerhard.steinmetz.fort...@t-online.de> 
---
Please note : both examples from pr70949 are simplifications of
this PR, thus related. Behaviour differs for -O0 (with/without ICE).
Compiling the example from above with optimization level -Og,
-Os, -O1 or higher shows the same ICE as in PR70949 comment 0.
In total, pr70949 is more or less a subcase.


Code compiles and works if "class" is changed to "type" :


$ cat z2.f90
program p
   type t1
   end type
   type t2
      type(t1), pointer :: q => null()
   end type
   type(t1), pointer :: a, b
   type(t2) :: c

   allocate(a)
   call s(a, c)
   print *, 'a', associated(a, f(c))

   b => f(c)
   print *, 'b', associated(a, b)

contains

   subroutine s(x, y)
      type(t1), pointer :: x
      type(t2), intent(out) :: y
      y%q => x
   end

   function f(x) result (z)
      type(t2), intent(in) :: x
      type(t1), pointer :: z
      z => x%q
   end
end


$ gfortran-6 -O0 -g z2.f90
$ a.out
 a T
 b T

Reply via email to