Microsoft KB Archive/49761

= FIX: F1001: p2symtab.c Initializing in COMMON or EQUIVALENCE =

Article ID: 49761

Article Last Modified on 12/1/2003

-

APPLIES TO


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

-



This article was previously published under Q49761



SYMPTOMS
When Microsoft FORTRAN compiles an application that contains a variable initialized in a type declaration that is also listed in an EQUIVALENCE statement, and the EQUIVALENCE statement appears first in the source code file, one of the following errors occurs. In FORTRAN versions 4.0 and 4.0a:

fatal error F1001: Internal Compiler Error

(compiler file '@(#)p2symtab.c:1.84', line 914)

In FORTRAN versions 4.01 and 4.10:

fatal error F1001: Internal Compiler Error

(compiler file '@(#)p2symtab.c:1.85', line 915)

In version 5.0, when an application contains a variable that is initialized in a type declaration or a DATA statement, the variable is also listed in a COMMON or EQUIVALENCE statement, and the type declaration or DATA statement appears first in the source code file, the following error occurs:

fatal error F1001: Internal Compiler Error

(compiler file '@(#)p2symtab.c:1.4', line 939)



RESOLUTION
In FORTRAN versions 4.x, modify the code such that variables that appear in a COMMON or EQUIVALENCE statement are not initialized. Use an assignment statement in the body of the code to give variables a value.

In version 5.0, use a DATA statement to initialize variables that appear in a COMMON or EQUIVALENCE statement or use an assignment statement in the body of the code to give variables a value.



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



MORE INFORMATION
FORTRAN versions 4.x do not support initializing variables that appear in COMMON or EQUIVALENCE statements. When the compiler detects such an attempt, it is designed to produce the following error messages:

error F2404: varname : can only initialize common block

in BLOCK DATA subprogram

error F2311: varname : EQUIVALENCE : preinitialization illegal

Often, the compiler correctly generates the first error message. However, instead of generating the second error, an internal compiler error occurs instead.

In version 5.0, the compiler was extended to allow this extension to the ANSI standard by allowing a DATA statement to assign a value to a variable. Support for initializing a value in a type declaration was not added. The compiler is designed to generate one of the following error messages when the code uses a type declaration to initialize a variable that appears in a COMMON or EQUIVALENCE statement:

error F2311: varname : COMMON : preinitialization illegal

-or-

error F2311: varname : EQUIVALENCE : preinitialization illegal

However, instead of generating the correct error message above, an internal compiler error occurs.

According to page 135 of the Microsoft FORTRAN &quot;Reference&quot; manual for version 5.0, the following example causes a compile-time error: INTEGER I /1/ COMMON I Page 165 of the &quot;Reference&quot; manual includes a similar warning about the EQUIVALENCE statement with the following code INTEGER I /1/ EQUIVALENCE (I, J) Compiling the following code with Microsoft FORTRAN versions 4.0, 4.0a, 4.01, or 4.1 generates an internal compiler error.

Sample Code #1
C Compiler options required: None

EQUIVALENCE (A, B)     INTEGER A      INTEGER B /1/ END Compiling either of the following code examples with Microsoft FORTRAN version 5.0 generates an internal compiler error.

Sample Code #2
C Compiler options required: None

INTEGER A     INTEGER B /1/ EQUIVALENCE (A, B)     END

Sample Code #3
C Compiler options required: None

INTEGER A     INTEGER B /1/ COMMON /TEST/ B     END The following code example demonstrates one method to avoid the compiler error in Microsoft FORTRAN version 5.0.

Sample Code #4
C Compiler options required: None

INTEGER A     INTEGER B      COMMON /TEST/ B      DATA B /1/ END

Additional query words: 4.00 4.00a 4.01 4.10 5.00 buglist4.00a buglist4.01 buglist4.10 buglist5.00 fixlist5.10

Keywords: kbfix KB49761

-

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

© Microsoft Corporation. All rights reserved.