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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org
                 CC|                            |pault at gcc dot gnu.org

--- Comment #10 from Paul Thomas <pault at gcc dot gnu.org> ---
Confirmed.

The argument in the interface is assumed shape, as expected, while its shadow
in the module procedure is tagged as deferred shape. Yet another fix (!):

index ba1c8bc322e..9e822f5c396 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -1464,8 +1464,12 @@ gfc_check_dummy_characteristics (gfc_symbol *s1,
gfc_symb
ol *s2,
     {
       int i, compval;
       gfc_expr *shape1, *shape2;
+      bool module_procedure;

-      if (s1->as->type != s2->as->type)
+      module_procedure = s1->ns->proc_name &&
+                        s1->ns->proc_name->attr.module_procedure;
+
+      if (s1->as->type != s2->as->type && !module_procedure)
        {
          snprintf (errmsg, err_len, "Shape mismatch in argument '%s'",
                    s1->name);

This fixes the problem but I rather think that the proper way to do it is
further upstream. decl.c(gfc_match_submod_proc) looks as if the array spec is
copied as it should be but I need to do a gdb session to check this. I'll have
to put my thinking cap on regarding Steve's offering in comment 5.

It should be noted that the submodule version works as intended in all versions
of gfortran for which submodules are implemented:

module foobar
  type foo
  contains
    procedure, nopass :: bar
  end type
  interface
    module subroutine bar(arg)
      character(len=*) arg(:)
    end subroutine
  end interface
end module

submodule (foobar) sbar
contains
  module procedure bar
    print *, arg
  end procedure
end submodule

  use foobar
  character(4) :: book(2) = ['abcd', 'efgh']
  call bar(book)
end


I'm onto it.

Thanks for the report

Paul

Reply via email to