This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Functions result assigned to an array subscript which is also an input parameter


Hi!

I've just spotted a very different behaviour between GFortan and the
Lahey compiler: the later gives the output I expect without any warning
of any kind (with all checks enabled), whereas GFortran surprises me a
bit...

I think this is a bug, as this only happens with array subscripts, but
this is so twisted that it might actually be OK...

Can anyone comment on that?

Thanks a lot!

Philippe

PS: lf95 returns '11 12 13' and gfortran '1           2           3'

PPS: the sources:
!
      MODULE Module_Test
          INTEGER, PARAMETER :: Array_Size = 3
      END MODULE Module_Test
!
      FUNCTION Function_Test ( Offset, Input )
          USE Module_Test
          INTEGER, INTENT(IN) :: Offset, Input(1:Array_Size)
          INTEGER :: Function_Test(1:Array_Size)
          Function_Test = Input + Offset
      END FUNCTION Function_Test
!
      PROGRAM Test
          USE Module_Test
          IMPLICIT NONE
          INTEGER :: Variable, Array(2,Array_Size)
          INTERFACE
              FUNCTION Function_Test ( Offset, Input )
                  USE Module_Test
                  INTEGER, INTENT(IN) :: Offset, Input(1:Array_Size)
                  INTEGER :: Function_Test(1:Array_Size)
              END FUNCTION Function_Test
          END INTERFACE
          DO Variable = LBOUND(Array,DIM=2), UBOUND(Array,DIM=2)
              Array(1,Variable)  = Variable
          END DO
          Array(1,:) = Function_Test ( 10, Array(1,:) )
          WRITE ( 6, * ) Array(1:1,:)
      END PROGRAM Test
!

PPPS: I'm running:
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /USER/philippe/Irix/Gcc_Sources/configure
--prefix=/usr1/MICRESS/Philippe/Tools/Gcc --enable-languages=c,fortran
--disable-maintainer-mode --with-mpfr=/usr1/MICRESS/Philippe/Tools/Mpfr
--with-gmp=/usr1/MICRESS/Philippe/Tools/Gmp
Thread model: posix
gcc version 4.2.0 20060411 (experimental)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]