Bug 28809 - No diagnostic for missing interface for same file procedure
Summary: No diagnostic for missing interface for same file procedure
Status: RESOLVED DUPLICATE of bug 26227
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on: 26227
  Show dependency treegraph
Reported: 2006-08-22 19:58 UTC by John Chodera
Modified: 2006-09-13 16:12 UTC (History)
5 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2006-09-12 09:10:55


Note You need to log in before you can comment on or make changes to this bug.
Description John Chodera 2006-08-22 19:58:44 UTC
Attempting to compile the following code gives the error message below:


recursive real function det(A) result(res)
  ! Parameters.
  real, dimension(:,:), intent(in) :: A
  ! Local variables.
  real :: d
  integer:: n
  n = size(A,1)
  d = 0.0
  if (n==2) then
     res = A(1,1)*A(2,2)-A(1,2)*A(2,1)
  else if (n==3) then
     d = A(1,1)*(A(2,2)*A(3,3)-A(3,2)*A(2,3))
     d = d-A(1,2)*(A(2,1)*A(3,3)-A(3,1)*A(2,3))
     d = d+A(1,3)*(A(2,1)*A(3,2)-A(3,1)*A(2,2))
     res = d
  else if (n==4) then
     res = A(1,1)*det(A((/2,3,4/),(/2,3,4/))) &
          -A(1,2)*det(A((/2,3,4/),(/1,3,4/))) &
          +A(1,3)*det(A((/2,3,4/),(/1,2,4/))) &
     write(*,*) 'det for matrices bigger than 4x4 not implemented'
  end if
end function det

program main
  real, dimension(4,4) :: A
  integer :: i,j

  do i = 1,4
     do j = 1,4
        call random_number(A(i,j))
     end do
  end do
  write(*,*) det(A)

end program main


[jchodera@opt2 detbug]$ gfortran -o detbug detbug.f90
detbug.f90: In function 'det':
detbug.f90:21: internal compiler error: in gfc_conv_ss_descriptor, at fortran/trans-array.c:1265
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.
[jchodera@opt2 detbug]$ gfortran --version
GNU Fortran 95 (GCC 4.0.2 20051125 (Red Hat 4.0.2-8))
Copyright (C) 2005 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
Comment 1 kargl 2006-08-22 20:53:35 UTC
Upgrade your compiler to at least 4.1.1, and try again.

Also, you need an  explicit interface for the
recursive function in your main program

  recursive real function det(a) result(res)
     real, dimension(:,:), intent(in) :: a
  end function det
end interface
Comment 2 tobias.burnus 2006-08-22 21:08:55 UTC
Using gfortran 4.1.2 20060705 (prerelease) (SUSE Linux)
and GNU Fortran 95 (GCC) 4.2.0 20060822 (experimental)
it compiles and gives the output (from the program):

 det for matrices bigger than 4x4 not implemented

John Chodera, I would really recommend to update to 4.1.x or to 4.2-snapshots as gfortran in GCC 4.0.x is rather buggy. See http://gcc.gnu.org/wiki/GFortranBinaries for binary GCC versions.

In addition: As the NAG compiler points out:
Error: Explicit interface required for DET from MAIN - argument A (no. 1) is an assumed-shape array

The problem is that Fortran passes an array differently for A(*) or A(n) than for A(:). The latter is called assumed-shaped array and is an addition to Fortran 90 (the former also work with Fortran 77). In order to let the compiler know that you want to pass an assumed-shaped array, you need to either create a module, which contains the function "det", or you put it below "contains" in the "program" section or you write an interface in the "program" section.
Comment 3 Paul Thomas 2006-09-12 09:10:55 UTC

The ICE is fixed on recent versions of gfortran.  However, I am keeping the PR and  giving it a new summary because the lack of a warning on the assumed shape array is a problem that is related to others.

Please feel free to submit your problems, as (or if!) they come up.  It would help both you and us if you would update.  You will find binaries of version 4.2.0 at the gfortran wiki that I know work fine with RedHat.


Comment 4 Tobias Schlüter 2006-09-13 16:12:32 UTC
Again, the same theme as 26227.

*** This bug has been marked as a duplicate of 26227 ***