简体   繁体   中英

BSTR bstrRtf = 0xcccccccccccccccc <Bad Ptr> on debugging ( = CXX0030: Error: expression cannot be evaluated)

I am using an IXLMDOMDocument to load a xml file from a stream using

IXMLDOMDocument *pDomDoc = pDomDoc->load(vtHtmlSource, &vfSuccess);

After loading the stream (containing the xml contents) it creates a style sheet in order to get the content ident properly. The above part is working without any problem. I am sure about that but after that when A transform Node (stylesheet in to bstrRtf ) by doing as below -

BSTR bstrRtf;
hr  = pDomDoc->transformNode(m_pStyleSheetNode, &bstrRtf);
//on debugging we get m_pStyleSheetNode = 0x0000000002b77ba8 that means it is correct and stylesheet is created properly.
//but bstrRtf = 0xcccccccccccccccc <Bad Ptr>  = CXX0030: Error: expression cannot be evaluated 
//that means there is some problem here

if (hr) {
    hr = HRESULT_FROM_WIN32(GetLastError()); //this hr surprisingly returns OK(hr = S_OK)
}; 

I don't know why or how. It should not do so because in bstrRtf we have a very strange value. I expect it to give some error, but I don't know why it does so.

Could any one explain what it means by bstrRtf = 0xcccccccccccccccc <Bad Ptr> ? When would someone get this type of error? What is the meaning of 0xcccccccccccccccc <Bad Ptr> ?

when i intialize it with zero the error is instance->m_bstrRtf = 0x0000000000000000 <Bad Ptr> on debugging. and not working. but why it returns S_OK even after this??

bstrRtf is not initialized - it has no valid value yet. The actual value of 0xcccccccccccccccc is what MS fills the memory with so that it is possible to detect uninitalized variables.

This value is picked specifically so that it's "not a valid memory address" - that way, you can't accidentally or on purpose use the memory of an uninitialized variable without getting some sort of error or trap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM