Microsoft KB Archive/72920

= FIX: Incorrect Result Initializing INTEGER*1 Array =

Article ID: 72920

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 4.0
 * Microsoft FORTRAN Compiler 4.01
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q72920



SYMPTOMS
Programs compiled with Microsoft FORTRAN versions 4.0, 4.01, 4.1, 5.0, and 5.1 that initialize an integer*1 array with negative values (that is, -128 to -1), can give incorrect results when run under MS-DOS or OS/2.



RESOLUTION
Adding an executable statement that uses an element of the array within the DO-LOOP, or disabling loop optimization with /Od, /Odct, or /4Yb when compiling, can prevent the problem from occurring.



STATUS
Microsoft has confirmed this to be a problem in FORTRAN versions 4.0, 4.01, 4.1, 5.0, and 5.1. This problem was corrected in FORTRAN PowerStation.



MORE INFORMATION
The following program examples illustrate the problem:

  Initializing array using a DO-LOOP. integer*1 arr(2) do 10 i=1,2 arr(i) = -1 10   continue write(*,*) arr(1) write(*,*) arr(2) end   Initializing array using a single assignment statement (Microsoft FORTRAN versions 5.0 and 5.1 only). integer*1 arr(2) arr = -1 write(*,*) arr(1) write(*,*) arr(2) end 

The programs above produce the following output:

-1

-2

The following output should be produced:

-1

-1

To prevent the problem from occurring, add an executable statement that uses an element of the array within the DO-LOOP, or disable loop optimization with /Od, /Odct, or /4Yb when compiling.

Additional query words: 5.00 5.10

Keywords: kbfix KB72920

-

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

© Microsoft Corporation. All rights reserved.