https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120711
--- Comment #4 from Andre Vehreschild <vehre at gcc dot gnu.org> ---
(In reply to anlauf from comment #3)
> Indeed. valgrind reports an invalid read with -fcoarray=none.
> But I do not see this on 14-branch.
You are right. One does not see the invalid read on gcc-14.
But add two prints into the example:
program grow_type_array
type :: string_t
character(:), allocatable :: s
end type string_t
type(string_t) :: str
type(string_t), allocatable :: list(:)
! This works
allocate(list(0))
str = new_string("Hello!")
list = [list, str]
print *, str%s
deallocate(list)
! This segfaults on gfortran 15.1 but works on gfortran 14
! when using -fcoarray=single compile flag
allocate(list(0))
list = [list, new_string("Hello!")]
print *, list(0)%s
contains
type(string_t) function new_string(s) result(out)
character(*), intent(in) :: s
out%s = s
end function new_string
end program grow_type_array
and you get them. I consider those prints valid. So there is something strange
going on. I will investigate.