https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44265

--- Comment #16 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 38917
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38917&action=edit
Further development of the patch

This patch cures the problem described at the end of comment #1. The change in
trans-expr.c does the job.

However, for reasons that I cannot see at the moment, the len_trim is not doing
the trimming :-(

MODULE Fruits
  IMPLICIT NONE
!  PRIVATE
!  PUBLIC :: Get
CONTAINS
  subroutine fruity3
    print *, get(4)
  end
  FUNCTION Get(i) RESULT(s)
    CHARACTER(*), PARAMETER :: names(4) = [  &
        'Apple  ',  &
        'Orange ',  &
        'Mango  ',  &
        'Pear   ' ];
    INTEGER, INTENT(IN) :: i
    CHARACTER(LEN_trim(names(i))) :: s
    !****
    s = names(i)
    print *, len(s)
  END FUNCTION Get
  subroutine fruity2
    print *, get(3)
  end
END MODULE Fruits

PROGRAM WheresThatbLinkingConstantGone
  USE Fruits
  IMPLICIT NONE
  !****
  WRITE (*, "('Eat the tasty ',A)") Get(1)
  call fruity
  call fruity2
  call fruity3
contains
  subroutine fruity
    print *, get(2)
  end
END PROGRAM WheresThatbLinkingConstantGone

outputs

Eat the tasty            5
Apple
           6
 Orange
           5
 Mangoe
           4
 Pearoe

I am sure that the problem is now trivial... A task for tomorrow.

Paul

Reply via email to