This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/72709] Incorrect assignment of allocatable character array used as component of derived type
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 14 Dec 2016 23:10:03 +0000
- Subject: [Bug fortran/72709] Incorrect assignment of allocatable character array used as component of derived type
- Auto-submitted: auto-generated
- References: <bug-72709-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72709
--- Comment #4 from janus at gcc dot gnu.org ---
Extension / variation of the test case:
program read_exp_data
implicit none
type experimental_data_t
character(len=:), dimension(:), allocatable :: header
end type
type(experimental_data_t) :: ex
integer, parameter :: nh = 3
integer :: i
allocate(character(len=2) :: ex%header(nh))
ex%header(3) = "C"
ex%header(2) = "B"
ex%header(1) = "A"
do i = 1, nh
write(*,*) "header(",i,") = ", ex%header(i), " loc: ", loc(ex%header(i))
enddo
end program
This prints:
header( 1 ) = A loc: 16642032
header( 2 ) = A loc: 16642032
header( 3 ) = A loc: 16642032
which shows that the problem is apparently not only in the writing into the
array, but also in the output. All elements appear to have the same address!