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

Last reviewed: September 11, 1997
Article ID: Q49761
4.00 4.00a 4.01 4.10 5.00 | 4.10 5.00
MS-DOS                    | OS/2
kbtool kbfixlist kbbuglist kberrmsg

The information in this article applies to:

  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.0a, 4.01, 4.1, 5.0
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0

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 "Reference" manual for version 5.0, the following example causes a compile-time error:

      INTEGER I /1/
      COMMON I

Page 165 of the "Reference" 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 reference words: 4.00 4.00a 4.01 4.10 5.00 buglist4.00a
buglist4.01 buglist4.10 buglist5.00 fixlist5.10
KBCategory: kbtool kbfixlist kbbuglist kberrmsg
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.