Microsoft KB Archive/69762

= FIX: Mixed Type Expressions Cause F2124: Code Generation Error =

Article ID: 69762

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 4.0
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 4.1
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q69762



SYMPTOMS
Using Microsoft FORTRAN 5.0 or 5.1 to compile a program that uses mixed data types in an expression can cause the compiler to hang the machine under DOS, generate a protection violation under OS/2, or result in the following error:

F2124: Code Generation Error

In some cases, the compiler will generate the following error:

fatal error F1001: Internal Compiler Error

(compiler file '@(#)mactab.c:1.2', line 663)

Explicitly converting all variables and constants to the same type will suppress the error.

In some cases, the error is suppressed by optimization (for example, using /Ox, or by not using the /Od compiler option during compilation). In other cases, the problem is more severe when using optimization.



CAUSE
The following sample programs illustrate the problems.

Using COMPLEX and REAL Data Types
subroutine x(a,c,d) complex*16 a, d, b      b = (1.0,0) a = a * (-b) * c * d      return end The above program must be compiled with the /Od switch to cause the code generation error. In some cases, the /FPc option may be necessary to generate F2124.

Using COMPLEX instead of COMPLEX*16 will generate the following error:

fatal error F1001: Internal Compiler Error

(compiler file '@(#)mactab.c:1.2', line 663)

Using REAL and INTEGER Data Types
real a,b,c b = 1.0 c = 2.0 a = 4 * b * (-1) * c      end Compiling this program under DOS without the /Od compiler option will cause the compiler to hang the computer. When compiling under OS/2, a protection violation is generated by the second pass of the compiler. Using the /Od compiler option results in the following error:

F2124: Code Generation Error



RESOLUTION
Explicitly converting the type of all of the variables or constants to the same type will prevent the errors, as illustrated by the following sample programs:

Using COMPLEX and REAL Data Types
subroutine x(a,c,d) complex*16 a, d, b      b = (1.0,0) a = a * (-b) * dcmplx(c) * d   ! Convert real data type to                                      ! double precision complex ! data type to match other ! types. return end

Using REAL and INTEGER Data Types
real a,b,c b = 1.0 c = 2.0 a = 4.0 * b * (-1.0) * c       ! Convert integer constants ! to real constants to match ! other types. end



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

Additional query words: 5.00 5.10

Keywords: kbfix KB69762

-

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

© Microsoft Corporation. All rights reserved.