Menu

#3 GCC 3.3 static_cast errors

open
nobody
None
5
2003-10-18
2003-10-18
No

When building with GCC 3.3 there are several instances
of static_cast errors in the files

xnest/xnest.cpp
xpair/xpair.cpp
xtail/main.cpp

In all cases the error is with the statement

_Assign(&static_cast<IUnknownCL*>(m_pchOut),
m_pchCur)

The workaround I implemented was to change the
statement to

_Assign(&m_pchOut, m_pchCur)

and change the _Assign() function's signature from

inline void _Assign(IUnknownCL **ppunk, IUnknownCL
*punk)

to

inline void _Assign(ITSAXContentHandler **ppunk,
ITSAXContentHandler *punk)

That is, the static cast was unnecessary everywhere it
was used.

Discussion

  • Andrew Gilmartin

    Logged In: YES
    user_id=305143

    I forgot: from searching the web it seems that GCC 3.2 would
    accept this cast was a bug in GCC 3.2.

     
  • Matthew Walker

    Matthew Walker - 2004-04-07

    Logged In: YES
    user_id=879263

    I followed those suggestions and, thankfully, was able to
    get things to compile. A slight modification to the patch
    was required however.

    Line 313 in xnest/xnext.cpp:
    _Assign(static_cast<IUnknownCL*>(m_pchCur), m_pchOut);
    was changed to:
    _Assign(&m_pchCur, m_pchOut);
    rather than:
    _Assign(&m_pchOut, m_pchCur)

    Line 158 in xpair/xpair.cpp:
    _Assign(&static_cast<IUnknownCL*>(m_pchOut), m_pchCur);
    was changed to:
    _Assign(&m_pchOut, m_pchCur);

    Line 278: in xtail/main.cpp:
    _Assign(&static_cast<IUnknownCL*>(m_pchCur), m_pchOut);
    was changed to:
    _Assign(&m_pchCur, m_pchOut);

    Line 264 in xtail/main.cpp:
    _Assign(&static_cast<IUnknownCL*>(m_pchCur), m_pchOut);
    was changed to:
    _Assign(&m_pchCur, m_pchOut);

    The suggested changes for "inline void _Assign(IUnknownCL
    **ppunk, IUnknownCL*punk)" are correct.

     

Log in to post a comment.