Microsoft KB Archive/24628

From BetaArchive Wiki

Article ID: 24628

Article Last Modified on 12/1/2003



APPLIES TO

  • Microsoft FORTRAN Compiler 4.0
  • Microsoft FORTRAN Compiler 4.0a
  • Microsoft FORTRAN Compiler 4.01
  • Microsoft FORTRAN Compiler 4.1
  • Microsoft FORTRAN Compiler 5.0
  • Microsoft FORTRAN Compiler 4.1
  • Microsoft FORTRAN Compiler 5.0



This article was previously published under Q24628

SYMPTOMS

An application generates incorrect results. When FORTRAN for MS-DOS versions 4.0, 4.0a, or 4.01 compiles the program, the compiler generates the following message:

warning F4803 FUNCTION : return variable not set

CAUSE

The problem occurs because the compiler requires the return value of an entry to be set using the entry name. The ANSI FORTRAN-77 standard states that the return value can be set using the entry name or the original function name if they have the same type.

RESOLUTION

To work around this problem, set the return value of a entry that is part of a function by using the entry name instead of the function name.

STATUS

Microsoft has confirmed this to be a problem in FORTRAN versions 4.0, 4.0a, 4.01, 4.10, and 5.00 for MS-DOS and versions 4.1 and 5.0 for OS/2. This problem was corrected in FORTRAN version 5.10 for MS-DOS and OS/2.

MORE INFORMATION

Pages 15-12 and 15-13 of the ANSI FORTRAN-77 standard include the following statement.

15.7.3 Entry Association. Within a function subprogram, all variables whose names are also the names of entries are associated with each other and with the variable, if any, whose name is also the name of the function subprogram (17.1.3). Therefore, any such variable that becomes defined causes all associated variables of the same type to become defined and all associated variables of different type to become undefined.


Therefore, it should be possible to set the return value of an entry that belongs to a function through the function name or the entry name if both have the same type.

The following code example demonstrates this problem.

Sample Code #1

C Compile options needed: None

      PROGRAM TEST
      INTEGER FUN1, ENT1
      WRITE (*, *) FUN1(3), ENT1(3)
      END

      INTEGER FUNCTION FUN1(I)
      INTEGER ENT1

      FUN1 = I
      RETURN

      ENTRY ENT1(I)

      FUN1 = 2 * I
      RETURN
      END
                

The following code example demonstrates one method to avoid this problem.

Sample Code #2

C Compile options needed: None

      PROGRAM TEST
      INTEGER FUN1, ENT1
      WRITE (*, *) FUN1(3), ENT1(3)
      END

      INTEGER FUNCTION FUN1(I)
      INTEGER ENT1

      FUN1 = I
      RETURN

      ENTRY ENT1(I)

      ENT1 = 2 * I
      RETURN
      END
                


Additional query words: 4.00 4.00a 4.01 4.10 5.00 buglist4.00 buglist4.00a buglist4.01 buglist4.10 buglist5.00 fixlist5.10

Keywords: kbfix KB24628