https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128042
--- Comment #4 from Harald Anlauf <anlauf at gcc dot gnu.org> ---
Somewhat reduced testcase:
program test
implicit none
type tag3
character(4) :: c3(2) = ""
end type tag3
type tag2
type(tag3) :: t3(2)
end type tag2
! type(tag2), parameter :: x = tag2(tag3(['opqr','strv'])) ! fails too
type(tag2), parameter :: x = tag2(tag3( 'opqr' ))
type(tag2) :: y = x
integer, parameter :: n = storage_size (x) / 8
integer :: k = n
character, dimension(n) :: zz1, zz2, zz3, zz4
zz1 = transfer(x,'*',k) ! not simplified (k is variable)
zz2 = transfer(y,'*',k)
zz3 = transfer(y,'*',n) ! not simplified (ytag is variable)
zz4 = transfer(x,'*',n) ! <<< bad simplification
print *, zz1
print *, zz2
print *, zz3
print *, zz4
end
This prints:
opqropqropqropqr
opqropqropqropqr
opqropqropqropqr
opqr^@^@^@^@^@^@^@^@^@^@^@^@
The simplification of TRANSFER fails for (nested?) derived types.