https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86328
--- Comment #12 from martin <mscfd at gmx dot net> ---
The workaround mentioned by Paul in comment #9 is working only partially. For
character sequences (and possibly other data types), valgrind still complains.
Surprisingly, using a single character works as well. On the other with three
or more characters, valgrind sees one more invalid read than with two
characters. The workaround for me was to switch to a string derived-type, which
encapsulates the character variable. Then I only see memory leaks, but no
invalid reads, or other serious stuff.
Here is the variation which still shows the problems with a character constant:
program classstar_alloc3
type :: t
class(*), allocatable :: val
end type
type :: list
type(t), dimension(:), pointer :: ll
end type
integer :: i
type(list) :: a
allocate(a%ll(1:2))
do i = 1,2
allocate(a%ll(i)%val, source='01')
end do
call rrr(a)
contains
subroutine rrr(a)
type(list), intent(in) :: a
class(*), allocatable :: c
! allocate(c, source=a%ll(2)%val)
c = a%ll(2)%val
end subroutine
end program classstar_alloc3