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

--- Comment #2 from anlauf at gcc dot gnu.org ---
Another reduced variant:

program arrays10
  implicit none
  character(5), allocatable :: a(:)
  character(:), allocatable :: b(:)
  a = [ character(5) :: "one", "two", "three"]
  b = [ character(5) :: "one", "two", "three"]
  call test02 (a) ! OK
  call test02 (b) ! OK
  call test02 (a(size(a):1:-1)) ! OK
  call test02 (b(size(b):1:-1)) ! random junk or crash
contains
  subroutine test02 (a)
    character(*), intent(in) :: a(:)
    print *, a
  end
end

This prints at runtime e.g.

% ./a.out | cat -ev
 one  two  three$
 one  two  three$
 threetwo  one  $
 one  ^@^@^@^@^@^@^@!^@^@$

Forcing an explicit temporary helps, as with

  call test02((b(size(b):1:-1)))

***

The uninitialized warnings Steve mentions corresponds to issues visible
in the tree dump: it appears the the length .b is used before it is set.

Reply via email to