This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/77360] New: Self-assignment of allocatable character array
- From: "damian at sourceryinstitute dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 24 Aug 2016 05:20:56 +0000
- Subject: [Bug fortran/77360] New: Self-assignment of allocatable character array
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77360
Bug ID: 77360
Summary: Self-assignment of allocatable character array
Product: gcc
Version: 6.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: damian at sourceryinstitute dot org
Target Milestone: ---
As demonstrated below, the assignment of an allocatable character array element
to itself leads to erroneous results 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:
$ 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