PRB: Debugger Displays Incorrect Information for Variable (168080)



The information in this article applies to:

  • Microsoft Visual C++, 32-bit Editions 5.0
  • Microsoft Visual C++, 32-bit Editions 6.0

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 ;
       }
     
    						

Modification Type:MajorLast Reviewed:10/2/2003
Keywords:kbBug kbDebug kbide kbprb KB168080 kbAudDeveloper