https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81093
--- Comment #2 from janus at gcc dot gnu.org ---
Confirmed. Slightly reduced test case:
program test
implicit none
type data_type1
integer, dimension(2) :: data1 = (/1,2/)
end type
type, extends(data_type1) :: data_type2
integer, dimension(2) :: data2 = -1
end type
type data_gen
class(data_type1), dimension(:), allocatable :: mydata
end type
type(data_gen) :: gen_data
allocate(data_type2::gen_data%mydata(2))
! wrong result
write(*,*) gen_data%mydata(:)%data1(1), gen_data%mydata(:)%data1(2)
! correct result
select type(data => gen_data%mydata)
type is (data_type2)
write(*,*) data(:)%data1(1), data(:)%data1(2)
end select
end program test
It ICEs with gfortran 4.7 and shows the same (wrong) output with all later
versions:
1 -1 2 -1
1 1 2 2
The second line is right, the first is wrong (should be equal to the second).