https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65766
--- Comment #3 from Louis Krupp <t56xjcu6dh at snkmail dot com> --- Created attachment 36080 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36080&action=edit Proposed patch The problem is with substrings of allocatable string components of derived types. The code seems to be trying to get the string length from typespec of the derived type variable instead of from the component. The attached patch gets the component typespec from the reference chain. I don't understand the code well enough to have a lot of confidence in this patch, but it seems like a step in the right direction.