FIX: Compiler Hangs When Adjustable-Size Array Used Improperly

Last reviewed: September 11, 1997
Article ID: Q67515
5.00 | 5.00 MS-DOS | OS/2 kbtool kbfixlist kbbuglist

The information in this article applies to:

  • Microsoft FORTRAN for MS-DOS and 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 reference words: 5.00 buglist5.00 fixlist5.10
KBCategory: kbtool kbfixlist kbbuglist
KBSubCategory: FLIss
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 11, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.