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

            Bug ID: 86119
           Summary: Intrinsic len has wrong type if used within select
                    type for a class(*) string
           Product: gcc
           Version: 8.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mscfd at gmx dot net
  Target Milestone: ---

The following program, compiled with -Wall gives the warning

       l2 = len(s)
           1
Warning: Possible change of value in conversion from INTEGER(8) to INTEGER(4)
at (1) [-Wconversion]

(No warning for len_trim!)

This is directly related to the use of select type in conjunction with
class(*).
If s is declared as character(len=:) and the select type block is removed, then
there is no warning.


program proglen

implicit none

   class(*), allocatable :: s
   integer :: l1, l2

   allocate(s, source = '123  ')

   select type(s)
   type is (character(len=*))
      l1 = len_trim(s)
      l2 = len(s)
   end select

end program proglen

Reply via email to