https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80945
--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- Still fails with current trunk. Code from comment#1, somewhat simplified: program main implicit none integer:: i integer, parameter:: N = 10 character(len=:), dimension(:),allocatable:: ca allocate(character(len=N):: ca(3)) ca(1) = "foo" ca(2) = "bar" ca(3) = "xyzzy" write (*, '(3A5)') ca(1:3) end program This yields on gcc110: foo foo foo Looking at the tree dump, we see MAIN__ () { integer(kind=8) .ca; struct array01_unknown ca; bitsizetype D.2078; sizetype D.2079; D.2078 = (bitsizetype) (sizetype) NON_LVALUE_EXPR <.ca> * 8; D.2079 = (sizetype) NON_LVALUE_EXPR <.ca>; and later { integer(kind=4) overflow.0; .ca = 10; ca.dtype = {.elem_len=(unsigned long) SAVE_EXPR <(sizetype) NON_LVALUE_EXPR <.ca>>, .rank=1, .type=6}; ... _gfortran_st_write (&dt_parm.1); { struct array01_unknown parm.2; parm.2.dtype = {.elem_len=(unsigned long) SAVE_EXPR <D.2079>, .rank=1, .type=6}; parm.2.dim[0].lbound = 1; parm.2.dim[0].ubound = 3; parm.2.dim[0].stride = 1; parm.2.data = (void *) &(*(character(kind=1)[0:][1:.ca] * restrict) ca.data)[1 - ca.dim[0].lbound]; parm.2.offset = ca.offset; _gfortran_transfer_array_write (&dt_parm.1, &parm.2, 1, .ca); so the dtype gets its elem_len from the uninitialized copy of .ca instead of the correctly initialized value later. Paul, does this ring any bells?