KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q45094: -FPc Generates Call to __fld1 with ++ Operator

Article: Q45094
Product(s): See article
Version(s): 5.10   | 5.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | buglist5.10 | mspl13_c
Last Modified: 19-SEP-1989

In certain cases, code that uses the post increment operator on a
float variable causes the Microsoft C 5.10 compiler to generate a call
to __fld1. This function is not present in any of the Microsoft C
libraries and results in an unresolved external at link time. If the
post increment is performed on the right side of an assignment
statement and the code is compiled for floating point coprocessor
calls, the reference to __fld1 will be made. The following program
demonstrates the problem when compiled with this command line:

    cl -FPc file.c

    /* file.c */
    void main(void) {
        float a;
        a = a++;        /* Generates call to __fld1 */
        a++;            /* Does not generate call to __fld1 */
        a += 1.0;       /* Does not generate call to __fld1 */
    }

fld1 is an 8087 instruction that increments a real by 1.0. Microsoft
has chosen not to emulate this instruction. The call to this
instruction is a code generation error on the part of the compiler.

To work around this problem, add 1.0 to the variable instead of using
the post increment operator. Compilation with the -FPi (default)
option does not produce such an error. Compiling for floating point
emulation math eliminates the problem as well.

Microsoft has confirmed this to be a problem with C Version 5.10. We
are researching this problem and will post new information as it
becomes available.

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.

Copyright Microsoft Corporation 1986-2002.