[Bug fortran/57839] New: Reallocate on assignment does not work properly
jwmwalrus at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Jul 6 19:19:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57839
Bug ID: 57839
Summary: Reallocate on assignment does not work properly
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: jwmwalrus at gmail dot com
The following program does not produce the expected results with either
gfortran 4.8 or gfortran 4.9:
program test_lhs_allocate
use iso_fortran_env
implicit none
type :: table
character(63) :: name = ''
character(63), allocatable :: alias(:)
end type
integer :: i, j
type(table), allocatable :: list(:)
type(table) :: item
allocate (list(1:0)) !empty list
item%name = 'name'
item%alias = [character(63) :: 'label']
list = [list, item]
item%name = 'id'
item%alias = [character(63) :: ]
list = [list, item]
item%name = 'status'
item%alias = [character(63) :: 'state', 'validity', 'test']
list = [list, item]
!item%name = 'other'
!item%alias = [character(63) :: 'extra', 'additional', 'more']
!list = [list, item]
do i = 1, SIZE(list)
write (OUTPUT_UNIT, '(/"name: ", A,/,"aliases: ", *(A,:,","))') &
TRIM(list(i)%name), &
(TRIM(list(i)%alias(j)), j = 1, SIZE(list(i)%alias))
enddo
end program test_lhs_allocate
The actual output is:
...:~$ gfortran-4.9 -std=f2008 test_lhs_allocate.f90
...:~$ ./a.out
name: name
aliases: ���
name: id
aliases:
name: status
aliases: state,validity,test
What is expected:
name: name
aliases: label
name: id
aliases:
name: status
aliases: state,validity
If I enable the three commented lines, then the output is:
...:~$ gfortran-4.9 -std=f2008 test_lhs_allocate.f90
...:~$ ./a.out
name: name
aliases: ���
name: id
aliases:
name: status
aliases: name,�����������id,
�����
name: other
aliases: extra,additional,more
It seems as if every time an item is added to the list, all the aliases in the
previous items are lost.
The system information is:
...:~$ ll `which gfortran-4.9` && /usr/lib/gcc-snapshot/bin/gfortran -v &&
apt-cache policy gfortran-4.8 gcc-snapshot && lsb_release -rd
lrwxrwxrwx 1 root staff 34 Jul 5 12:58 /usr/local/bin/gfortran-4.9 ->
/usr/lib/gcc-snapshot/bin/gfortran*
Using built-in specs.
COLLECT_GCC=/usr/lib/gcc-snapshot/bin/gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc-snapshot/libexec/gcc/x86_64-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 20130620-1'
--with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs
--enable-languages=c,ada,c++,java,go,fortran,objc,obj-c++
--prefix=/usr/lib/gcc-snapshot --enable-shared --enable-linker-build-id
--disable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-snap-amd64/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-snap-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-snap-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --with-tune=generic --disable-werror
--enable-checking=yes --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.0 20130620 (experimental) [trunk revision 200244] (Debian
20130620-1)
gfortran-4.8:
Installed: 4.8.1-5
Candidate: 4.8.1-5
Version table:
*** 4.8.1-5 0
200 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
100 /var/lib/dpkg/status
4.8.1-2 0
500 http://ftp.us.debian.org/debian/ testing/main amd64 Packages
gcc-snapshot:
Installed: 20130620-1
Candidate: 20130620-1
Version table:
*** 20130620-1 0
200 http://ftp.us.debian.org/debian/ unstable/main amd64 Packages
100 /var/lib/dpkg/status
Description: Debian GNU/Linux testing (jessie)
Release: testing
More information about the Gcc-bugs
mailing list