[comp.lang.fortran] Compiler confusion between functions and subroutines.

lagache@violet.berkeley.edu.UUCP (10/01/87)

          Hello FORTRAN hackers everywhere!

               Right on the heals of my recent report of "interesting"
          parsing by 'f77', I have a lulu for you.  Yesterday a student
          came to me with a very interesting program which had the same
          character as the following:

                INTEGER I,J,SQUARE
                I=4
                CALL SQUARE(I,J)
                PRINT *,I,J
                STOP
                END

                INTEGER FUNCTION SQUARE(I,J)
                INTEGER I,J
                J = I**2
                RETURN
                END

               Impossible?  Worse than that, it worked!  The fellow
          said that he was using version 2 of MS-FORTRAN for the Mac.
          A quick check of the FORTRANs that I could look at gives the
          following tally:

               UTAH FORTRAN accepts the code and it runs "correctly"

               MS-FORTRAN 3.X for PC and f77 finds the error.

               I wonder how many compilers out there are guilty of this
          affliction?


                                        Edouard Lagache
                                        School of Education
                                        U.C. Berkeley
                                        lagache@violet.berkeley.edu

jkw@a.UUCP (Jay Wooten) (10/02/87)

In article <5288@jade.BERKELEY.EDU>, lagache@violet.berkeley.edu (Edouard Lagache) writes:
> 
> 
>           Hello FORTRAN hackers everywhere!
> 
>                Right on the heals of my recent report of "interesting"
>           parsing by 'f77', I have a lulu for you.  Yesterday a student
>           came to me with a very interesting program which had the same
>           character as the following:
> 
>                 INTEGER I,J,SQUARE
>                 I=4
>                 CALL SQUARE(I,J)
>                 PRINT *,I,J
>                 STOP
>                 END
> 
>                 INTEGER FUNCTION SQUARE(I,J)
>                 INTEGER I,J
>                 J = I**2
>                 RETURN
>                 END
> 
>                Impossible?  Worse than that, it worked!  The fellow
>           said that he was using version 2 of MS-FORTRAN for the Mac.
>           A quick check of the FORTRANs that I could look at gives the
>           following tally:
> 
>                UTAH FORTRAN accepts the code and it runs "correctly"
> 
>                MS-FORTRAN 3.X for PC and f77 finds the error.
> 
>                I wonder how many compilers out there are guilty of this
>           affliction?
> 
> 
>                                         Edouard Lagache
>                                         School of Education
>                                         U.C. Berkeley
>                                         lagache@violet.berkeley.edu


  BSD 4.3 : "Declaration error for square: incompatable type declarations"

  VMS 4.5 : Accepts the code and it runs "correctly"










































pad
pad
pad