FIX: Mixed Type Expressions Cause F2124: Code Generation Error

Last reviewed: September 11, 1997
Article ID: Q69762
4.00 4.10 5.00 5.10 | 4.10 5.00 5.10
MS-DOS              | OS/2
kbtool kbfixlist kbbuglist kberrmsg kbcode

The information in this article applies to:

  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.1, 5.0, and 5.1
  • Microsoft FORTRAN for OS/2, versions 4.1, 5.0, 5.1

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 reference words: 5.00 5.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.