FIX: Compiler Hangs When Adjustable-Size Array Used Improperly

ID: Q67515


The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, version 5.0
  • Microsoft FORTRAN for OS/2, version 5.0


SYMPTOMS

An attempt to compile an application in MS-DOS fails and the computer hangs. An attempt to compile the same application in OS/2 fails and the compiler prints some high-ASCII characters on the screen followed by a protection violation message. An attempt to compile the application with Microsoft FORTRAN versions 4.0 or 4.1 fails and the compiler generates one of the following messages:

F2841: adjustable-size array: not reference argument'
F2339: adjustable-size array not in subprogram


CAUSE

The application contains an adjustable size array that is not a formal argument to a subprogram.


RESOLUTION

To address this problem, perform one of the following steps:

  • Modify the source code to declare the array as an argument to a subprogram.


  • Modify the source code to declare the array as ALLOCATABLE and allocate it.



STATUS

Microsoft has confirmed this to be a problem in FORTRAN version 5.0 for MS-DOS and OS/2. This problem was corrected in FORTRAN version 5.1 for MS-DOS and OS/2.


MORE INFORMATION

On page 145, the Microsoft FORTRAN "Reference" manual for versions 5.0 and 5.1 explains how an adjustable sized array must be a formal argument of the program unit in which the array appears. On the other hand, an allocatable array must not be a formal argument. For more information on allocatable arrays, see pages 25 and 113 of the "Reference" manual.

The following code example reproduces this problem in a subprogram.

Sample Code #1


C Compile options needed: None

       SUBROUTINE A (B, C)
       DIMENSION B(1, 1), D(C, 1, 1)
       E = 1
       D(E, E, E) = D(1, 1, 1) + B(1, 1) * D(1, 1, 1)
       END 
The error depends on both the assignment statements and arithmetic in the second statement. For example, if you change the left-hand side of the equation in the second assignment statement to "D(1, 1, 1)" from "D(E, E, E)," the compiler generates the correct error message.

The following code example reproduces this problem in a main program.

Sample Code #2


C Compile options needed: None

       DIMENSION B(1, 1), D(C, 1, 1)
       E = 1
       D(E, E, E) = D(1, 1, 1) + B(1, 1) * D(1, 1, 1)
       END 

Additional query words: 5.00 buglist5.00 fixlist5.10

Keywords :
Version : :5.0
Platform :
Issue type :


Last Reviewed: November 2, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.