Consider the following code:
module m contains pure integer function mysize(a) integer,intent(in) :: a(:) mysize = size(a) end function end module program prog use m implicit none character(3) :: str integer :: i(3) = (/1,2,3/) str = p(i,mysize) print *,str,len(str) contains function p(y,asz) implicit none integer :: y(:) interface pure integer function asz(c) integer,intent(in) :: c(:) end function end interface character(asz(y)) p integer i do i=1,asz(y) print *,y(i),achar(iachar('A')+y(i)) p(i:i) = achar(iachar('A')+y(i)) end do print *,p,len(p) end function end Compiling this with GCC trunk rev. 141361 does work, but when running the produced binary the output is: 1 B 2 C 3 D BCD 3 B 3 The first four lines are ok, but the last one should actually be equal to the second to last one. The program does give the expected ouput when the implementation of mysize is changed such that it always returns a constant (e.g. "3"). Compiling with 4.3.1 gives an ICE. Compiling with g95 works and gives the right output. -- Summary: Program gives wrong output (connected to char len) Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: janus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37926