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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-08-14
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from anlauf at gcc dot gnu.org ---
Confirmed.

A reduced testcase giving the same failure may give some insight:

module strings
  implicit none
contains
  pure function charArrToString(data)
    character, intent(in) :: data(:)
!   character(size(data))       :: charArrToString ! OK
    character(ubound(data,1))   :: charArrToString ! ICE if used in main
    charArrToString = ""
  end function charArrToString
end module strings

program test_str
  use strings
  implicit none
  character :: c(2) = (/ 'T', 'T' /)
  write(*,*) "write module-", charArrToString(c),  "-" ! ICE
  write(*,*) "write module-", charArrToString2(c), "-" ! OK
contains
  pure function charArrToString2(data)
    character, intent(in) :: data(:)
!   character(size(data))       :: charArrToString2 ! OK
    character(ubound(data,1))   :: charArrToString2 ! OK
    charArrToString2 = ""
  end function charArrToString2
end program test_str

So (apparently):
- if the function definition is in the same compilation unit as where it is
  used, there is no problem.
- if the function interface is passed via a module file, some declarations
  work (e.g. using the SIZE intrinsic), but some don't (e.g. using a pure
  user-defined function, or some other intrinsics).

Reply via email to