BUG: F1001: Code.c, Line 428, Arrays of Structures

Last reviewed: July 24, 1995
Article ID: Q86070
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, version 5.1
  • Microsoft FORTRAN for OS/2, version 5.1

SYMPTOMS

Using the Microsoft FORTRAN version 5.1 compiler with the /MW or /G2 option to compile code that contains an array of structures in an output statement may generate the following error:

   fatal error F1001: Internal Compiler Error
                      (compiler file '@(#)code.c:1.31', line 428)

To generate the error, the array must be indexed using INTEGER*1 variables and the elements of the structure must not have been assigned values.

CAUSE

This is an optimization problem with common sub-expression elimination; compiling with /Odc and /MW generates the error but compiling with /Odtl and /MW does not. Note that the /MW option automatically invokes the /G2 option.

RESOLUTION

The following are several different solutions to this problem:

  1. Compile with /Odtl to suppress optimization for common sub-expression elimination.

    -or-

  2. Avoid the use of INTEGER*1 variables as array subscripts.

    -or-

  3. Initialize the member(s) of the structure prior to its use in an output statement. Sample code #2 demonstrates this last solution.

    -or-

  4. Eliminate /MW from the command line. When compiling a QuickWin program, /MW (without a number it defaults to /MW1) is placing calls to the YIELDQQ() function before going into DO-loops. However, the programmer can manually insert these calls; therefore, compiling without a /MW switch is equivalent to to /MW0 [no YIELDQQ() call inserted] and the problem is eliminated because the /G2 option is not invoked.

STATUS

Microsoft has confirmed this to be a problem in FORTRAN version 5.1.

This is not a problem with FORTRAN PowerStation.

MORE INFORMATION

The following code reproduces the problem.

This code must be compiled as a QuickWin program (FL /MW Sample.FOR)

Sample Code 1

C Compile options needed: /MW

      STRUCTURE /MyStruct/
        INTEGER*2    IntNum
        REAL*4       RealNum
      END STRUCTURE

      RECORD /MyStruct/ MyRec(1)
      INTEGER*1 i

      i = 1                          ! Initialize subscript index

      WRITE (*,*) MyRec(i).IntNum    ! Write variable to the screen
      WRITE (*,*) MyRec(i).RealNum

      END

This code, compiled as a QuickWin program (FL /MW Sample.FOR), does not generate the error:

Sample Code 2

C Compile options needed: /MW

      STRUCTURE /MyStruct/
          INTEGER*2    IntNum
          REAL*4       RealNum
      END STRUCTURE

      RECORD /MyStruct/ MyRec(1)
      INTEGER*1 i

      i = 1                            ! Initialize subscript index

      MyRec(i).IntNum  = 123           ! Initialize structure members
      MyRec(i).RealNum = 3.1415927

      WRITE (*,*) MyRec(i).IntNum      ! Write variable to the screen
      WRITE (*,*) MyRec(i).RealNum

      END


Additional reference words: 5.10
KBCategory: kbtool kbfixlist kbbuglist kberrmsg
KBSubcategory: FLIss


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: July 24, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.