DOCERR: Iteration Count Overflow in 5.0 and 5.1 Manuals (70193)



The information in this article applies to:

  • Microsoft FORTRAN Compiler for MS-DOS 5.0
  • Microsoft FORTRAN Compiler for MS-DOS 5.1
  • Microsoft FORTRAN compiler for OS/2 5.0
  • Microsoft FORTRAN compiler for OS/2 5.1

This article was previously published under Q70193

SUMMARY

On pages 149 and 150 of the version 5.0 and version 5.1 "Microsoft FORTRAN Reference" manual, the iteration count for DO loops is incorrectly stated to default to INTEGER*2 storage. DO loop iteration counts actually appear to default to the same precision as the DO variable, except when the start value and stop value are constants, rather than variables. In this case, the DO loop iteration count appears to default to INTEGER*4 storage.

MORE INFORMATION

Page 150 states that "The iteration count is computed using two-byte precision (the default)", and the code on page 150 of the Reference Manual illustrates an iteration overflow when compiled with /4Yb or $DEBUG. However, declaring the DO variable 'n' as integer*4 or removing the IMPLICIT statement removes the iteration overflow, indicating that the iteration count precision is dependent on the precision of the DO variable. This is demonstrated by the code below, which both compiles and runs without errors, even when compiled with /4Yb or $DEBUG:

Sample code

$DEBUG

      IMPLICIT INTEGER*2 (A-Z)
      INTEGER*4 N
      stop=32000
      start=0
      step=1200
      DO 100 n=start,stop,step
100   CONTINUE
      END
				
Declaring the DO variable as INTEGER*2 and the rest of the variables as INTEGER*4 generates an integer overflow error when compiled with /4Yb or $DEBUG.

Sample code

$DEBUG

      INTEGER*4 start,stop,step
      INTEGER*2 N
      stop=32000
      start=0
      step=1200
      DO 100 n=start,stop,step
100   CONTINUE
      END
				
Therefore, the iteration count precision is dependent on the precision of the DO variable. Furthermore, the code on page 149 does not cause the iteration overflow error as stated. This code is as follows:

Sample code

$DEBUG

      INTEGER*2 i
      DO 10 i=-32000,32000,1
10    CONTINUE
      END
				
This code executes without error when compiled with /4Yb or $DEBUG, indicating that when constants are used for the start and stop values, the iteration count defaults to INTEGER*4 precision.

Modification Type:MajorLast Reviewed:12/1/2003
Keywords:KB70193