FIX: No Code Generated for Assignment Statement

Last reviewed: September 18, 1997
Article ID: Q114072
7.00 | 1.00 MS-DOS | WINDOWS kbtool kbfixlist kbbuglist

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE), included with:

        - Microsoft C/C++ compiler for MS-DOS, version 7.0
        - Microsoft Visual C++ for Windows, version 1.0
    

SYMPTOMS

No code is generated for an assignment statement. In the following sample, the program never terminates because no code is generated for the statement that sets the condition for terminating the loop.

CAUSE

This problem occurs when one or more of the -Oe, -Og, and -Ol optimizations are used.

RESOLUTION

To avoid the problem disable the optimizations. This can be done by either not using the /Oe, Og or /Ol options on the command line or by using #pragma optimize to disable the optimizations in the source file. The comments in the sample below demonstrate using #pragma optimize statements to work around the problem.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed above. This is not a problem in Visual C++, 32-bit Edition. This problem was corrected in Visual C++ version 1.5.

Sample Code

/* Compile options needed: /Oe, /Og, /Ol, or any combination of these
*/

#include <stdio.h>

static int fault = 0, state ;

// Uncomment for work around
// #pragma optimize ("egl", off)

int TestFunc (void)
{
    if (state == 2)
    {
        state=0;         // No code generated for this block
        /* state=0; */   // Works if this line's comment is removed

        if (fault == 0)
            return(1);
        else
            return(-1);
    }
    else
        return(0);
}

// Uncomment for work around
// #pragma optimize ("", on)

void main(void)
{
    state = 2;
    while ( TestFunc() == 1)
        printf("Should loop once.\n");
}


Additional reference words: 7.00 8.00 1.00
KBCategory: kbtool kbfixlist kbbuglist
KBSubcategory: CLIss
Keywords : CLIss kb16bitonly kbbuglist kbfixlist kbtool
Version : 7.00 | 1.00
Platform : MS-DOS WINDOWS
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 18, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.