DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4581>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4581 erroneous static cast in programming examples ------- Additional Comments From [EMAIL PROTECTED] 2001-11-02 06:49 ------- With multiple inheritance, you cannot cast like that to get at the sub-objects of an object. Your code is different because you're assigning a pointer from the object, so the compiler knows how to adjust the pointer for the particular type of subobject. In fact, your code needs no casts, and I wouldn't recommend using them. If you don't believe me, compile your code and run it in the debugger. You'll see that ch and eh contain different addresses. The code in question creates a DefaultHandler, but assigns it to a variable that's a ContentHandler*. Then that pointer is cast to a DefaultHandler, which results in undefined behavior. With RTTI and dynamic_cast, you _can_ discover the address of the base object and safely do the cast to ErrorHandler, but that's not being done here. C-style casts are very error-prone in this sense. Unfortunately, Xerces opted to avoid the newer casts. If you try this cast with a real static_cast<>, the compiler will refuse to do it. I think this bug is mis-titled, because this is not a static_cast<>, but a C-style cast, which is why the compiler didn't catch the error. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
