public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/48959] New: Dummy procedure: Argument mismatch not diagnosed
@ 2011-05-11  8:17 burnus at gcc dot gnu.org
  2013-08-27 11:18 ` [Bug fortran/48959] " mikael at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-05-11  8:17 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Dummy procedure: Argument mismatch not diagnosed
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


Found at:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/1a40cc3e6e4546de/

The dummy procedure has as first dummy argument:
      real, intent(in) :: p(:)
whereas the procedure which is passed as actual argument has as dummy argument:
      real, intent(in) :: param(3)

However, gfortran fails to diagnose this. I think the reason is that as dummy
argument "p" and "param" are compatible; however, as dummy argument of a
procedure they are not.


The check has to be added into interface.c's gfc_compare_interfaces - which
should be rather simple.

Currently, for each argument rank, optional attribute and intent is checked.
One there as to add a check that either both or neither is an assumed-shape
array. (Deferred-shape can be handled via an ALLOCATABLE/POINTER attribute
check.) Additionally, one should check for other characteristics (cf. 12.3.2):
CONTIGUOUS, VALUE, ALLOCATABLE, POINTER, TARGET, ASYNCHRONOUS, VOLATILE, type
parameters (currently, only: string lengths), corank. The procedure itself
should be checked for BIND(C) and PUREness.

Cf. also:

"12.5.2.9 Actual arguments associated with dummy procedure entities

"If the interface of a dummy procedure is explicit, its characteristics as a
procedure (12.3.1) shall be the same as those of its effective argument, except
that a pure effective 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 cannot be elemental)."


NAG diagnoses the problem as:
  Error: line 31: Dummy proc SUBR arg 1 is assumed-shape, actual proc
                  MYSUB arg is not
  Error: line 31: Incompatible procedure argument for SUBR (no. 2) of MINIM


Example program by Clive Page:

module mymod
implicit none
contains
!---------------------------------------------------------
subroutine mysub(param, result)
real, intent(in) :: param(3)
real, intent(out) :: result
print *,'param=', param
result = 0.0
end subroutine mysub
!---------------------------------------------------------
subroutine minim(param, subr, result)
real, intent(in) :: param(:)
interface
    subroutine subr(p, r)
      real, intent(in) :: p(:)
      real, intent(out) :: r
    end subroutine subr
end interface
real, intent(out):: result
!
call subr(param, result)
end subroutine minim
end module mymod
!----------------------------------------------------------

program main
use mymod
implicit none
real :: param(3) = [1.0, 2.0, 3.0], result
call minim(param, mysub, result)
end program main


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug fortran/48959] Dummy procedure: Argument mismatch not diagnosed
  2011-05-11  8:17 [Bug fortran/48959] New: Dummy procedure: Argument mismatch not diagnosed burnus at gcc dot gnu.org
@ 2013-08-27 11:18 ` mikael at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: mikael at gcc dot gnu.org @ 2013-08-27 11:18 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |mikael at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #1 from Mikael Morin <mikael at gcc dot gnu.org> ---
Both 4.8 and trunk(4.9) now output:

comment_0.f90:32.18:

call minim(param, mysub, result)
                  1
Error: Interface mismatch in dummy procedure 'subr' at (1): Shape mismatch in
argument 'p'


I think that's acceptable as a diagnostic.
Closing as FIXED.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-27 11:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-11  8:17 [Bug fortran/48959] New: Dummy procedure: Argument mismatch not diagnosed burnus at gcc dot gnu.org
2013-08-27 11:18 ` [Bug fortran/48959] " mikael at gcc dot gnu.org

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).