This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Bug 77360 - Self-assignment of allocatable character array yields erroneous result
- From: Damian Rouson <damian at sourceryinstitute dot org>
- To: gfortran <fortran at gcc dot gnu dot org>
- Cc: maxwell dot kelley at nasa dot gov, Tom Clune <thomas dot l dot clune at nasa dot gov>
- Date: Tue, 23 Aug 2016 22:29:07 -0700
- Subject: Bug 77360 - Self-assignment of allocatable character array yields erroneous result
- Authentication-results: sourceware.org; auth=none
Gfortran developers,
As demonstrated below, the assignment of an allocatable character array element to itself leads to an erroneous result with gfortran 6.1.0. The same code yields the correct output ('a') with gfortran 5.4.0 and 7.0.0. Dead code plays a role: the "if (.false.)" statement is required to demonstrate the problem.
Damian
$ cat self-assign-char-array.f90
character(1), allocatable :: linelist(:)
linelist = ['a']
if (.false.) linelist(1) = linelist(1)
linelist(1) = linelist(1)
print *,linelist(1)
end
$ gfortran self-assign-char-array.f90
$ ./a.out
$ gfortran —version
GNU Fortran (MacPorts gcc6 6.1.0_0) 6.1.0