http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57354
Bug ID: 57354
Summary: Wrong run-time assignment of allocatable array of
derived type with allocatable component
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: vladimir.fuka at gmail dot com
Created attachment 30154
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30154&action=edit
realloc.f90
source:
type t
integer,allocatable :: i
end type
type(t) :: e
type(t), allocatable :: a(:)
do i=1,100
e%i = i
if (.not.allocated(a)) then
a = [e]
else
a = [a, e]
end if
end do
print *, (a(i)%i, i=1,size(a))
end
gcc version 4.8.1 20130509 (prerelease) (GCC)
expected result: 1,2..100
actual result:
gfortran realloc.f90
./a.out
32338624 32338560 32338496 32338432 32338368 32338304
32338240 32338176 32338112 32338048 32337920 32337856
32337792 32337728 32337664 32337600 32337536 32337472
32338016 32337952 32337232 32337168 32337104 32337040
32336976 32337408 32337344 32336816 32336752 32336688
32336624 32336096 32336032 32335968 32336912 32336512
32336448 32336384 32336352 32336288 32336224 32335872
32336160 32335680 32335248 32334864 32334528 32334240
32333952 32333888 32333952 32334240 32334528 32334864
32335248 32335680 32336160 32335872 32336224 32336288
32336352 32336384 32336448 32336512 32336912 32335968
32336032 32336096 32336624 32336688 32336752 32336816
32337344 32337408 32336976 32337040 32337104 32337168
32337232 32337952 32338016 32337472 32337536 32337600
32337664 32337728 32337792 32337856 32337920 32338048
32338112 32338176 32338240 32338304 32338368 32338432
32338496 32338560 32338624 100
(the garbage differs on each run)