BUG: Native Expression Evaluator in Visual Studio .NET Cannot Evaluate Many Overloaded Operators (318557)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2002)
  • Microsoft Visual C++ .NET (2003)

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.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. 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.
  2. Open the project name.cpp file of the project, and then add the following code:
    #include "stdafx.h"
    
    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;
    }
    					
  3. Build the application.
  4. Set a breakpoint on the last statement ("return 0").
  5. To start the debugger, press F5. The debugger stops at the breakpoint.
  6. In the watch window, type ~o.
Result: You receive the error message.

REFERENCES

For more information about expression evaluators, visit the following Microsoft Developer Network (MSDN) Web site: For more information about expressions in the Visual Studio .NET debugger, visit the following MSDN Web site:

Modification Type:MajorLast Reviewed:4/5/2006
Keywords:kbBug kbDebug kbpending KB318557