Microsoft KB Archive/67515

= FIX: Compiler Hangs When Adjustable-Size Array Used Improperly =

Article ID: 67515

Article Last Modified on 10/23/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.0

-



This article was previously published under Q67515



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 &quot;Reference&quot; 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 &quot;Reference&quot; 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 &quot;D(1, 1, 1)&quot; from &quot;D(E, E, E),&quot; 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: kbfix KB67515

-

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

© Microsoft Corporation. All rights reserved.