Knowledge Base

PRB: Debugger Displays Incorrect Information for Variable

Article ID: 168080

Article Last Modified on 10/2/2003


APPLIES TO


This article was previously published under Q168080

SYMPTOMS

When you debug an optimized build of an application that includes debug information, the debugger may display incorrect symbol data.

RESOLUTION

You can work around this problem by displaying the desired variable in a dialog box or printing it out using cout or printf();

MORE INFORMATION

The debugger displays incorrect symbol data when debugging an application built with the following compiler options:
  • /Oy (Frame-Pointer Omission)
  • /Og (Global Optimizations)
  • /Zi or /Z7 (Debug Info)

Steps to Reproduce Behavior

  1. Create a console application that includes the code listed below.
  2. Set the active configuration to Release.
  3. In the project Settings dialog box, click the C/C++ tab and select Program Database in the Debug Info list box.
  4. In the Project Settings dialog box, click the Linker tab and select the "Generate debug info" check box.
  5. Set a breakpoint in Something().
  6. Press the F5 key to build and debug the application.
       //Compiler options needed: /GX /Oy /Og /MLd
       #include <windows.h>
       #include <iostream>
    
       void Something(DWORD dwFirst, DWORD dwSecond)
       {
          // cout will display the correct information.
          std::cout << "dwFirst = " << dwFirst << ", dwSecond = " << dwSecond
          << std::endl;
       }
    
       int main()
       {
          DWORD dwFirst = 123456;
          DWORD dwSecond = 234567;
    
          Something(dwFirst, dwSecond);
          return 0 ;
       }
     
    						

Keywords: kbbug kbide kbdebug kbprb KB168080