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

            Bug ID: 84922
           Summary: fortran reports inconsistency in rank of arguments in
                    interface and contained procedures
           Product: gcc
           Version: 7.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: w.clodius at icloud dot com
  Target Milestone: ---

When compiling modules it is sometimes useful to provide an interface for the
contained procedure. For some of my procedures gfortran 7.1 is reporting an
inconsistency in the ranks for some of the arguments. This has occurred for
using a simple interface, a generic interface, or for using an interface for a
procedure defined in a submodule. The following file causes the problem for
fortran 7.1

module copy

    use, intrinsic :: iso_fortran_env, only : int8


    interface

        module subroutine copy_byte_data( data, copy ) ! Chase's copier
            integer(int8), intent(in)               :: data(:)
            integer(int8), allocatable, intent(out) :: copy(:)
        end subroutine copy_byte_data

    end interface



contains


    subroutine copy_byte_data( data, copy ) ! Chase's copier
        integer(int8), intent(in)               :: data(:)
        integer(int8), allocatable, intent(out) :: copy(:)

        if ( allocated( copy ) ) then
            deallocate( copy )
        end if
        allocate( copy( size(data) ) )
        copy = data

        return

    end subroutine copy_byte_data

end module copy

program test_copy

    use copy

    integer(int8)              :: data(8) = 0_int8
    integer(int8), allocatable :: acopy(:)

    write(*,*) 'DATA = ', data

    call copy_byte_data( data, acopy)

    write(*, *) 'ACOPY = ', acopy

    stop

end program test_copy

When compiled from the Terminal command line on Mac OS X 10.13.3, using the
command
gfortran test_copy.f90

I get the following response

test_copy.f90:21:35:

     subroutine copy_byte_data( data, copy ) ! Chase's copier
                                   1
Error: Shape mismatch in argument 'data' at (1)
test_copy.f90:39:8:

     use copy
        1
Fatal Error: Can't open module file ‘copy.mod’ for reading at (1): No such file
or directory
compilation terminated.

Reply via email to