Microsoft KB Archive/86070

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

Article ID: 86070

Article Last Modified on 10/23/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q86070



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-


 * 1) Avoid the use of INTEGER*1 variables as array subscripts. -or-


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


 * 1) 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: KB86070

-

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

© Microsoft Corporation. All rights reserved.