This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: c++/4248: reinterpret_cast in template


"Denkhaus, Volker" wrote:
> 
> Hi,
> 
> it is hard to provide a sample. First of all it needs the Runtime and SDK of
> our product (DCOM for Linux), plus the application project of our customer.
> This would be a lot of stuff. Also I currently do not know if I am allowed
> to forward the customer stuff (source also inlcuded). Would it help to send
> only the binaries and some of our source files (at least the file where the
> dump occurs which is in a hedaer file that belongs to our SDK).
no. I suspect your build has become skewed, most probably a header file
has changed and some object file has not been recompiled, or
you're picking up the wrong version of a library.
ldd can tell you the libraries being used.

If you can't reduce it down to a simple test case, because whenever you
do the bug goes away, then it is incredably likely to be version skew.

> This is the code:
                    template <class Base>
                    class CComTearOffObject : public Base
                    {
                    public:
                    CComTearOffObject(void* pv)
                    {
                    ATLASSERT(m_pOwner == NULL);
                    this->m_pOwner = reinterpret_cast<CComObject<typename Base::_OwnerClass>*>(p
                    v);
                    this->m_pOwner->AddRef();
                    }

                    The AddRef call ends up in a segmentation fault. In the debugger I can see that the address of the
                    function AddRef which can be found in the vtable is calculated wrong.

is m_powner the expected value?, what is its type? How is the address
calculated wrong? Is the compiler using the wrong index into the vtable,
or does the right index contain the wrong value?


nathan

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]