https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126479
--- Comment #2 from Mikael Morin <mikael at gcc dot gnu.org> ---
Here is a variant with a function result:
program p
implicit none
type :: t1
integer :: c1
end type
class(t1), pointer :: ptr(:)
ptr => class_ptr()
print *, storage_size(ptr)
contains
function class_ptr()
class(t1), pointer :: class_ptr(:)
nullify(class_ptr)
end function
end program
It gives a segmentation fault at execution time.
On pointer function results, f2023-15.6.2.2(Procedures defined by subprogram)
contains:
If the function result is a pointer, on return the pointer association
status of the function result shall not be undefined.
So it doesn't forbid disassociated pointer results.