ID: Q24628
4.00 4.00A 4.01 4.10 5.00 | 4.10 5.00
MS-DOS | OS/2
kbprg kbfixlist kbbuglist kbcode
The information in this article applies to:
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
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.
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.
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.
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.
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.
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 reference words: 4.00 4.00a 4.01 4.10 5.00 buglist4.00
buglist4.00a buglist4.01 buglist4.10 buglist5.00 fixlist5.10
KBCategory: kbtool kbfixlist kbbuglist kbcode
KBSubCategory: FLIss
Solution Type : kbfix
Last Reviewed: April 30, 1998