Microsoft KB Archive/168380

= BUG: Incorrect Evaluation of Static Member Functions in Debugger =

Article ID: 168380

Article Last Modified on 12/8/2003

-

APPLIES TO

 The Integrated Debugger, when used with:  Microsoft Visual C++ 4.0 Standard Edition

 Microsoft Visual C++ 4.1 Subscription

 Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q168380

<div class="symptoms_section">

SYMPTOMS
Function evaluation of static member functions cannot be done in the Watch or the QuickWatch window of the debugger. You a wrong value, or get the following error message:

Error:cannot display value

<div class="cause_section">

CAUSE
The expression evaluator in the debugger does not properly distinguish between static and non-static methods. The first case listed above appears to be an evaluation of a method without a "this" pointer, hence, we get an "Error:cannot display value" message. The second case occurs because the debugger is not properly distinguishing between static and non-static member functions. The "this" pointer is pushed onto the stack to evaluate the static member function, which is incorrect.

<div class="resolution_section">

RESOLUTION
There is no workaround. Do not attempt to evaluate static member functions from within the debugger, either in the watch or quick watch window.

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce Behavior
Use the following sample code and build it with debug information:

class A   { public: static int bar (int i) {return i;} };

void main {     A  f;      int j = A::bar(200); int i = f.bar(100); }

Start the debugger by stepping into (F11 key) function "main." In the Watch or QuickWatch window, type A::bar(200) and you will get the error message described in the SYMPTOMS section. Typing f.bar(100) produces a wrong value.

Keywords: kbbug kbide kbdebug KB168380

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.