public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/35831]  New: Type-mismatch check missing for dummy procedure argument
Date: Sat, 05 Apr 2008 08:33:00 -0000	[thread overview]
Message-ID: <bug-35831-13404@http.gcc.gnu.org/bugzilla/> (raw)

In the following program, the interface of the dummy procedure is explicit.

Fortran 2003's "12.4.1.3 Actual arguments associated with dummy procedure
entities" has about this:

"If the interface of the dummy argument is explicit, the characteristics listed
in 12.2 shall be the same for the associated actual argument and the
corresponding dummy argument, except that a pure actual argument may be
associated with a dummy argument that is not pure and an elemental intrinsic
actual procedure may be associated with a dummy procedure (which is prohibited
from being elemental)."

"If an external procedure name or a dummy procedure name is used as an actual
argument, its interface shall be explicit or it shall be explicitly declared to
have the EXTERNAL attribute."


gfortran does not seem to check whether the array arguments of dummy procedures
match. One reason could be that passing a "a(2)" array ("call foo(a)") to an
array "a(:)" is valid, but this does not apply here.

For some reason, gfortran checks this for
  PROCEDURE(<interface>) :: dummy
but not for
  INTERFACE; subroutine dummy() ...
in principle I had expected that both is handled identically. Remove the "!!"
to test the PROCEDURE version.

Found at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/330df81363912681

Please also check the version given there (incl. the PROCEDURE version) when
fixing this PR.

program test
  implicit none
  interface
    subroutine one(a)
      integer a(:)
    end subroutine one
    subroutine two(a)
      integer a(2)
    end subroutine two
  end interface
  ! PROCEDURE dummy, gives error:
  !! call foo(two)    ! OK: "Type/rank mismatch in argument 'f'"
  ! Interface dummy, is accepted:
  call bar(two)  ! Invalid, not diagnosed
contains
! Valid, but gives an ICE in trans-*.c, see PR 35830
!!  subroutine foo(f)
!!    procedure(one) :: f
!!  end subroutine foo

  subroutine bar(f)
    interface
      subroutine f(a)
        integer a(:)
      end subroutine f
    end interface
  end subroutine bar
end program test


-- 
           Summary: Type-mismatch check missing for dummy procedure argument
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35831


             reply	other threads:[~2008-04-05  8:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-05  8:33 burnus at gcc dot gnu dot org [this message]
2008-04-08 20:59 ` [Bug fortran/35831] " jaydub66 at gmail dot com
2008-04-09 18:24 ` jaydub66 at gmail dot com
2008-04-09 18:50 ` burnus at gcc dot gnu dot org
2008-04-10 21:10 ` jaydub66 at gmail dot com
2008-04-11  7:46 ` burnus at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-35831-13404@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).