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

            Bug ID: 104309
           Summary: Elemental character function should not return array
                    of character variables of different lengths.
           Product: gcc
           Version: fortran-dev
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vivekrao4 at yahoo dot com
  Target Milestone: ---

As discussed at
https://fortran-lang.discourse.group/t/elemental-character-function/2697 ,
gfortran compiles and runs

module m
contains
elemental function mytrim(x) result(y)
character (len=*), intent(in) :: x
character (len=len_trim(x))   :: y
y = trim(x)
end function mytrim
end module m
!
program test_mytrim
use m
print "(a,'_')", mytrim(["Fortran","Julia  "])
end program test_mytrim

giving output

Fortran_
Julia_

but I think g95 is correct in saying

In file mytrim.f90:5

character (len=len_trim(x))   :: y
                        1
Error: Dummy variable 'x' at (1) of an ELEMENTAL procedure cannot appear in a
specification expression

Reply via email to