Re: Strange member pointer error - even the debugger is confused.

From: CheckAbdoul (checkabdoul)
Date: 07/12/04


Date: Mon, 12 Jul 2004 12:11:52 -0400

Initialize m_pHead in your constructor to NULL. Something like

    CGeneric::CGeneric(....)
    {
        m_pHead = NULL;
    }

    0xCDCDCDCD is a debugging value that comes from C runtime library. Take
a look at
            http://www.microsoft.com/msj/1198/c/c1198.aspx

-- 
Cheers
Check Abdoul [VC++ MVP]
-----------------------------------
"Aaron Lawrence" <aaronlNO@SPAMintegration.co.nz> wrote in message
news:%23524UbCaEHA.1248@TK2MSFTNGP11.phx.gbl...
> Hi all,
>
> This may not exactly be a language problem but I couldn't find a
> .compiler group.
>
> We have a pretty typical COM object, whose declaration starts
>
> class ATL_NO_VTABLE CIfsf :
> public CComCoClass<CIfsf, &CLSID_Ifsf>,
> public IDispatchImpl<IPumpDriver, &IID_IPumpDriver, &LIBID_IFSFLib>,
> public CGeneric
> {
>
> which was made with the ATL COM AppWizard.
>
> Class CGeneric is declared:
>
> class CGeneric :
>    public CComObjectRootEx<CComMultiThreadModel>
> ...
> protected:
>    TBuff*    m_pHead ;
>
>
> the problem is that the code is seeing different values (addresses
> pointed at) of m_pHead, depending on whether it is accessed in CGeneric
> or in CIfsf. For instance, code in the CGeneric constructor initialises
> it to NULL, but later code in CGeneric sees it as non NULL.
>
> Why is that?
>
> I am sure that there is only the one declaration of m_pHead.
>
> The debugger only sees one value, the same as what code in CIfsf sees,
> when I step through it ... even stepping through the code which is in
> CGeneric (see screenshot attached). This implies it isn't confusion over
> C++ usage, to me.
>
> I've recompiled from scratch many times, and in the debug build there is
> no optimisation of course.
>
> This occurs even in the same thread (the application is multithreaded,
> but my test case isn't).
>
> I am kind of confused. What should I look for?
>
> Strangely, many other COM objects built on the same base CGeneric class
> work fine. Which in turn implies that it's just a matter of compiler
> settings, but I can't see anything obvious.
>
> The environment is VC6, SP6 on Windows 2000, SP3.
>
> ANY suggestions would be most welcome!
>
> Thanks
>
> Aaron
>
>
----------------------------------------------------------------------------
----


Relevant Pages

  • Re: Inherited Methods and such
    ... what I see in Initialize is ... Now, what you want is to get in the constructor of some S derived from T, ... The base types and registry are part of the framework and the user ... provides the concrete factories. ...
    (comp.lang.ada)
  • Re: Initializing static readonly methods
    ... public class TestClass ... //So assigning a value to readonly is perfectly fine. ... //readonly values are has to be initialized in constructor. ... There is no other place to initialize them. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: initialising properties in static constructor
    ... When static constructor is static it cannot initialize instance variables ... To intialize them in the constructor. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Initialization & Inheritance
    ... for a recent project I was trying to initialize members of a derived ... class from the constructor of the super class (done using an abstract ... initialize, but double initialization. ... if you used the pointer as it stood, ...
    (comp.lang.java.programmer)