public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33847]  New: Interface statement not detected: generate Error: Type/rank mismatch
@ 2007-10-21  6:53 m dot a dot hulsen at tue dot nl
  2007-10-21 10:07 ` [Bug fortran/33847] " burnus at gcc dot gnu dot org
  2007-10-21 10:33 ` burnus at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: m dot a dot hulsen at tue dot nl @ 2007-10-21  6:53 UTC (permalink / raw)
  To: gcc-bugs

The following code gives:

t.f90:41.12:

  call sub ( shape_line_P1 )
           1
Error: Type/rank mismatch in argument 'sub1' at (1)

I tested ifort, lahey, g95 without any problem.


module int_m
  interface shape_line_P1
    module procedure shape_line_P1, shape_line_P1_2
  end interface
contains
  subroutine shape_line_P1 ( xr, phi, dphi )
    real, intent(in), dimension(:) :: xr
    real, intent(out), dimension(:,:) :: phi
    real, intent(out), dimension(:,:), optional :: dphi
    phi = 0
    dphi = 0
  end subroutine shape_line_P1
  subroutine shape_line_P1_2 ( xr, phi, dphi )
    real, intent(in), dimension(:,:) :: xr
    real, intent(out), dimension(:,:) :: phi
    real, intent(out), dimension(:,:,:), optional :: dphi
    phi = 0
    dphi = 0
  end subroutine shape_line_P1_2
end module int_m
module tt
  use int_m
contains
   subroutine sub ( sub1 )
    interface
      subroutine sub1 ( xr, phi, dphi )
        real, intent(in), dimension(:,:) :: xr
        real, intent(out), dimension(:,:) :: phi
        real, intent(out), dimension(:,:,:), optional :: dphi
      end subroutine sub1
    end interface
    real, dimension(2,1) :: xr
    real, dimension(2,2) :: phi
    real, dimension(2,2,1) :: dphi
    xr = 0
   call sub1 ( xr, phi, dphi )
   end subroutine sub
end module tt
program z
  use tt
  call sub ( shape_line_P1 )
end program z


-- 
           Summary: Interface statement not detected: generate Error:
                    Type/rank mismatch
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: m dot a dot hulsen at tue dot nl


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


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

* [Bug fortran/33847] Interface statement not detected: generate Error: Type/rank mismatch
  2007-10-21  6:53 [Bug fortran/33847] New: Interface statement not detected: generate Error: Type/rank mismatch m dot a dot hulsen at tue dot nl
@ 2007-10-21 10:07 ` burnus at gcc dot gnu dot org
  2007-10-21 10:33 ` burnus at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-10-21 10:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-10-21 10:07 -------
(And the program is accepted using the patch from bug 33162 comment 2, however,
I think the patch is the wrong to solution for this PR and bug 33162.)

NAG f95 also gives the following error:

Error: line 41: Actual proc SHAPE_LINE_P1 arg 1 is assumed-shape or POINTER
array with different rank from dummy proc SUB1 arg
Error: line 41: Incompatible procedure argument for SUB1 (no. 1) of SUB

The program works if one changes
    call sub ( shape_line_P1 )    ! Generic  functions; specific: *_1, *_2
into
    call sub ( shape_line_P1_2 )  ! Specific function

Ad hoc, I expect that the program is valid, but I still have to check the
standard.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Interface statement not     |Interface statement not
                   |detected: generate Error:   |detected: generate Error:
                   |Type/rank mismatch          |Type/rank mismatch


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


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

* [Bug fortran/33847] Interface statement not detected: generate Error: Type/rank mismatch
  2007-10-21  6:53 [Bug fortran/33847] New: Interface statement not detected: generate Error: Type/rank mismatch m dot a dot hulsen at tue dot nl
  2007-10-21 10:07 ` [Bug fortran/33847] " burnus at gcc dot gnu dot org
@ 2007-10-21 10:33 ` burnus at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-10-21 10:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2007-10-21 10:33 -------
I cannot read. You used:

  interface shape_line_P1
    module procedure shape_line_P1, shape_line_P1_2
  end interface

Thus "shape_line_P1" is both a specific subroutine and a generic subroutine,
however, the standard mandates:

"If the specific name is also a generic name, only the specific procedure is
associated with the dummy argument."

And as the specific subroutine "shape_line_P1" does not match the interface of
sub's dummy argument "sub1", the program is invalid and the error printed by
gfortran and NAG f95 is correct.

To fix the program, change:
    call sub ( shape_line_P1 )    ! wrong specific function
into
    call sub ( shape_line_P1_2 )  ! correct specific function

-----------------

Now to the thing I read:

  interface shape_line_P1
    module procedure shape_line_P1_1, shape_line_P1_2
  end interface !_________________^^

which means that "shape_line_P1" is only a generic function and not a specific
function. However, this is also invalid and properly rejected by gfortran. The
standard writes:

For "a dummy procedure[...], the associated actual argument shall be the
specific name".

Here, gfortran writes:
"Error: GENERIC non-INTRINSIC procedure 'shape_line_p1' is not allowed as an
actual argument"

----------------

Longer excerpt from the Fortran 2003 standard:

"12.4.1.3 Actual arguments associated with dummy procedure entities"
[...]
"If a dummy argument is a dummy procedure without the POINTER attribute, the
associated actual argument shall be the specific name of an external, module,
dummy, or intrinsic procedure, an associated procedure pointer, or a reference
to a function that returns an associated procedure pointer. The only intrinsic
procedures permitted are those listed in 13.6 and not marked with a bullet (*).
If the specific name is also a generic name, only the specific procedure is
associated with the dummy argument."

----------------------------

Closed as invalid on this basis of this analysis.

Nonetheless, thanks for reporting bugs in general - as user feedback is
essential to iron out bugs and sometimes it is not obvious whether something is
a bug or not.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2007-10-21 10:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-21  6:53 [Bug fortran/33847] New: Interface statement not detected: generate Error: Type/rank mismatch m dot a dot hulsen at tue dot nl
2007-10-21 10:07 ` [Bug fortran/33847] " burnus at gcc dot gnu dot org
2007-10-21 10:33 ` burnus at gcc dot gnu dot 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).