Microsoft KB Archive/318557

= BUG: Native Expression Evaluator in Visual Studio .NET Cannot Evaluate Many Overloaded Operators =

Article ID: 318557

Article Last Modified on 4/5/2006

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition

-



This article was previously published under Q318557



SYMPTOMS
When you try to evaluate overloaded operators by using the native expression evaluator in the Visual Studio .NET debugger, you may receive the following error message:

Expression could not be evaluated.

The following is a list of operators that are known to give errors when they are overloaded:
 * binary ,
 * unary !
 * binary !=
 * binary %
 * binary %=
 * binary &
 * unary &
 * binary &&
 * binary &=
 * unary
 * binary *
 * unary *
 * binary *=
 * binary +
 * unary ++
 * unary +
 * binary +=
 * binary -
 * unary --
 * unary +
 * binary -=
 * binary /
 * binary /=
 * binary <
 * binary <<
 * binary <<=
 * binary <=
 * binary =
 * binary ==
 * binary >
 * binary >=
 * binary >>
 * binary >>=
 * binary []
 * binary ^
 * binary ^=
 * binary |
 * binary |=
 * binary ||
 * unary ~



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 In Microsoft Visual C++ .NET, create a new console application. To do this, open the New Project Wizard, and then select Win32 Application. In Application Settings, select Console application.  Open the .cpp file of the project, and then add the following code:
 * 1) include &quot;stdafx.h&quot;

class operatoroverload { public: int m_x;

// unary ~ operatoroverload& operator~ {       return *this; }

operatoroverload(void) {       m_x = 2; }

~operatoroverload(void) {   } };

int _tmain(int argc, _TCHAR* argv[]) {   operatoroverload o;

// unary ~ ~o;

return 0; }                    Build the application. Set a breakpoint on the last statement (&quot;return 0&quot;). To start the debugger, press F5. The debugger stops at the breakpoint. In the watch window, type ~o .</li></ol>

Result: You receive the error message.

<div class="references_section">