Microsoft KB Archive/77557

= FIX: Incorrect Results from Alternate Returns and $STORAGE:2 =

Article ID: 77557

Article Last Modified on 10/23/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q77557



SYMPTOMS
Microsoft FORTRAN code that uses alternate RETURNS and is compiled with $STORAGE:2 metacommand in the called subprogram and $STORAGE:4 (the default) in the calling routine may not return to the correct alternate return label number. This will cause incorrect results.



CAUSE
When the $STORAGE:2 metacommand is in the separately compiled subroutine with the alternate return, the AX register is correctly initialized with the return code but the DX register is not correctly initialized (zeroed), resulting in incorrect operation of the calling program. There is a CWD (convert to double word using DX:AX) missing in the generated code for the called subprogram. The calling routine acts on the fact that DX is not zero and branches to the next executable statement and not the correct alternate return label.



STATUS
Microsoft has confirmed this to be a problem in the products listed above. This problem was corrected in FORTRAN PowerStation.



MORE INFORMATION
The following code reproduces the problem:

Calling routine (in separate file):
PROGRAM TEST

CALL SUB1(*90) PRINT *, 'ERROR - NORMAL RETURN' STOP

90   PRINT *, 'CORRECT - ALTERNATE RETURN' STOP END

Called subprogram (in separate file):
$STORAGE:2 SUBROUTINE SUB1(*) RETURN 1 END

Additional query words: 5.10 buglist5.10 fixlist1.00

Keywords: KB77557

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.