BUG: this Pointer Expands Incorrectly for Multiple Inheritance

Last reviewed: July 22, 1997
Article ID: Q104676
4.10 | 1.00 1.50 1.51 1.52 4.10 MS-DOS | WINDOWS kbtool kbcode kbbuglist

The information in this article applies to:

  • Microsoft CodeView for MS-DOS, version 4.1
  • Microsoft CodeView for Windows, version 4.1
  • The integrated debugger included with:

          - Microsoft Visual C++ for Windows, versions 1.0, 1.5, 1.51, and 1.52
    

SYMPTOMS

Expanding the "this" pointer of a class with multiple inheritance displays incorrect information.

CAUSE

The class type is derived from more than one classes.

STATUS

Microsoft has confirmed this to be a problem in Microsoft CodeView version 4.1 for MS-DOS and Windows and in the Visual Workbench Debugger that ships with Visual C++ for Windows, version 1.0.

The problem does not occur with the Visual Workbench Debugger that ships with Visual C++ 32-bit Edition or with CodeView for Win32s version 4.25.

MORE INFORMATION

When you debug the sample code below, expanding the this pointer of the class collection in a Watch window displays the following:

-this = 0x45CA:0x09A2

  -base1 = {...}
    -base1 = CXX0030: Error: expression cannot be evaluated
      +base1 = CXX0030: Error: expression cannot be evaluated
      +base2 = CXX0030: Error: expression cannot be evaluated
       c = CXX0030: Error: expression cannot be evaluated
    -base2 = CXX0030: Error: expression cannot be evaluated
      +base1 = CXX0030: Error: expression cannot be evaluated
      +base2 = CXX0030: Error: expression cannot be evaluated
       c = CXX0030: Error: expression cannot be evaluated
     c = CXX0030: Error: expression cannot be evaluated
  -base2 = {...}
    +base1 = CXX0030: Error: expression cannot be evaluated
    +base2 = CXX0030: Error: expression cannot be evaluated
     c = CXX0030: Error: expression cannot be evaluated
   c = 12870

The base1 and base2 classes incorrectly appear more than once in the expanding process.

Sample Code

/*
 * Compiler options needed: /Zi /Od
 */

class base1{
   public:
   int a;
};

class base2{

   public:
   int b;
};

class collection:public base1,public base2 {

   public:
   int c;
   void sub();
};

void collection::sub()
{
   a=100;  // Set a breakpoint here and watch this pointer.
   b=200;
   c=300;
}

void main()
{
   collection k;
   k.sub();
}


Additional reference words: 4.10 1.00 1.50
KBCategory: kbtool kbcode kbbuglist
KBSubcategory: WBDebug CvwIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.