[Bug fortran/78803] New: deferred-length character components of derived types (allocatable string length) problem - ?regression
David.Duffy at qimr dot edu.au
gcc-bugzilla@gcc.gnu.org
Tue Dec 13 23:20:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78803
Bug ID: 78803
Summary: deferred-length character components of derived types
(allocatable string length) problem - ?regression
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: David.Duffy at qimr dot edu.au
Target Milestone: ---
PR51976 seems to suggest this used to work
module container
type c_data
character (len=:), dimension(:), allocatable :: str
end type c_data
end module container
program testalloc
use container
character (len=:), dimension(:), allocatable :: str
type(c_data) :: con
integer :: i, j, n
i=3
n=3
allocate(character(len=i) :: str(n))
allocate(character(len=i) :: con%str(n))
str(1)='ABC'
str(2)='DEF'
str(3)='123'
write(*,*) 'dim=', size(str), ' len=', len(str(1))
write(*,*) str(1)
do j=1, n
write(*,*) 'STR ->', str(j), '<- ', len(str(j))
end do
con%str(1)='ABC'
con%str(2)='DEF'
con%str(3)='123'
write(*,*) 'dim=', size(con%str), ' len=', len(con%str(1))
write(*,*) con%str(1)
do j=1, n
write(*,*) 'CON ->', con%str(j), '<- ', len(con%str(j))
end do
end program testalloc
Compiled with GNU Fortran (GCC) 7.0.0 20161213 (experimental) [trunk revision
243588] or 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
gives:
dim= 3 len= 3
ABC
STR ->ABC<- 3
STR ->DEF<- 3
STR ->123<- 3
dim= 3 len= 3
123
CON ->123<- 3
CON ->123<- 3
CON ->123<- 3
Works as I would expect with solarisstudio12.4 sunf95
More information about the Gcc-bugs
mailing list