This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

deferred-length character bug in optimized code


Gfortran developers,

I know the support for deferred-length character variables is evolving, but in case this issue isn't already known, below is a simple test case that demonstrates a problem that only appears in optimized code.  The first result below is the correct output.  The second result is the output at optimization levels -O1, -O2, and -O3.   Please let me know if I should submit a new PR.

Damian



$ cat trim.f90 
character(len=4) :: string="123 "
character(:), allocatable :: trimmed
trimmed = trim(string)
print *,len_trim(string),len(trimmed)
end 

$ gfortran trim.f90 
$ ./a.out 
           3           3
$ gfortran -O1 trim.f90 
$ ./a.out 
           3           4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]