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

            Bug ID: 125902
           Summary: -fc-prototypes incorrect for allocatable arrays and
                    allocatable and assumed length character strings
           Product: gcc
           Version: 15.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Nicholas.BREALEY at 3ds dot com
  Target Milestone: ---

Created attachment 64797
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64797&action=edit
input file

-fc-prototypes is a very useful feature but it generates incorrect C prototypes
for allocatable arrays and allocatable and assumed length character strings.

using:

gfortran -c -fc-prototypes test_c_prototypes_module.f90

on a file containing the code:

module test_c_prototypes_module

  use iso_c_binding
  implicit none (type, external)

  interface
    subroutine testsub(c, d, r, ier) bind(C)
      import
      character(kind=c_char,len=*), intent(in) :: c
      real(c_double), dimension(:), allocatable, intent(inout) :: d
      character(kind=c_char,len=:), allocatable, intent(inout) :: r
      integer(c_int), intent(out) :: ier
    end subroutine testsub
  end interface

end module test_c_prototypes_module 

should generate the prototype:

void testsub(const CFI_cdesc_t* c, CFI_cdesc_t* d, CFI_cdesc_t* r, int* ier);

but it generates:

void testsub (const char *c, double *d, char *r, int *ier);

Reply via email to