https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71862
--- Comment #1 from Gerhard Steinmetz <gerhard.steinmetz.fort...@t-online.de> --- Works when "class" is changed to "type" ... $ cat z2.f90 program p type t integer :: n = 0 integer, pointer :: q => null() end type type(t) :: x print *, associated(x%q) x = f() print *, associated(x%q) contains function f() result (z) type(t) :: z print *, associated(z%q) end end $ gfortran-7-20160710 z2.f90 $ a.out F F F