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

            Bug ID: 113911
           Summary: [14 Regression] Length is lost passing deferred-length
                    character to subroutine
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

As reported in

https://gcc.gnu.org/pipermail/fortran/2024-February/060224.html

the following testcase regressed after commit r14-8947:

program p
   implicit none
   integer, parameter :: n = 100, l = 10
   character(l) :: a = 'a234567890', b(n) = 'bcdefghijk'
   character(:), allocatable :: d, e(:)
   allocate (d, source=a)
   allocate (e, source=b)
   print *, len (d), len (e), size (e)
   call not_bindc_optional_deferred (d, e)
   deallocate (d, e)
contains
   subroutine not_bindc_optional_deferred (c5, c6)
     character(:), allocatable, optional :: c5, c6(:)
     if (.not. present (c5) .or. .not. present (c6)) stop 6
     print *, len (c5), len (c6), size (c6)
     if (len (c5) /= l .or. len (c6) /= l) stop 84
   end
end

Expected:

           10          10         100
           10          10         100

After above commit:

           10          10         100
           10           0         100
STOP 84

Reply via email to