Microsoft KB Archive/121887

= PRB: Debugger Can't Evaluate Cast of Enum to (long*) =

Article ID: 121887

Article Last Modified on 12/2/2003

-

APPLIES TO

 The Visual Workbench Integrated Debugger, when used with:  Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition

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

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

 Microsoft Visual C++ 4.0 Cross Development Edition for Macintosh</li></ul>

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

 Microsoft Visual C++ 2.1</li></ul>

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

 Microsoft Visual C++ 6.0 Service Pack 5</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q121887

<div class="symptoms_section">

SYMPTOMS
The Visual Workbench Debugger expression evaluator cannot evaluate the cast of an enumerator to a pointer to a long in C++ code. If you attempt to enter an expression of this type in the debugger's watch window, an error occurs. For example, if you try to watch the enumerator 'a' as shown in the sample code below, the debugger gives this error: <pre class="fixed_text">  (long*)a = CXX0019: Error: bad type cast The error occurs even though the cast is legal.

<div class="resolution_section">

RESOLUTION
If the enumerator is assigned to a pointer to a long at compile time, the debugger can watch the pointer (see the Sample Code section below).

<div class="status_section">

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

<div class="moreinformation_section">

MORE INFORMATION
The following sample code demonstrates the problem. Entering (long*)a in the Watch window causes error CXX0019.

Sample Code
/* Compile options needed: /Zi /Od test.cpp

enum {a=1, b=2, c=3};

void main {  long *ptr; ptr = (long*)a; // Cast works correctly in code. }

Keywords: kbbug kbide kbdebug kbprb KB121887

-

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

© Microsoft Corporation. All rights reserved.