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

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.


  2. -or-

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


  4. -or-

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


  6. -or-

  7. 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 query words: nofps 5.10

Keywords :
Version : :5.1
Platform :
Issue type :


Last Reviewed: November 1, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.