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

--- Comment #4 from anlauf at gcc dot gnu.org ---
Simplified testcase:

program test
  implicit none
  character(len=:), allocatable :: c, d
  c = scalar()             ! works with -fno-automatic
  print *, len(c)
  d = scalar_with_result() ! FAILS with -fno-automatic
  print *, len(d)
contains
  function scalar()
    character(len=:), allocatable :: scalar
    scalar = "abcdef"
    print *, len(scalar)
  end function scalar
  function scalar_with_result() result(c)
    character(len=:), allocatable :: c
    c = "abcdef"
    print *, len(c)
  end function scalar_with_result
end program test

As described by the reporter in comment#0, the result clause is somehow
mishandled here.  This prints with -fno-automatic:

           6
           6
           6
           0

Reply via email to