[Cppunit-devel] cppunit FAQ 2.3: Why does the test ExceptionTest.testAssignment f ailed in CppUnit
Brought to you by:
blep
From: Maxwell, J. (M. GEMS-IT) <Joh...@me...> - 2002-02-01 05:04:42
|
Gentlefolk: Dunno if this is a frequently answered question, but I've tracked it down, so I thought I'd post, just in case it isn't old news: Short form: The test fails because assignment of CppUnit::Exception objects is broken. Long form: In CppUnit::Exception::operator=, there's a call to SuperClass::operator=(). Under VC++, that doesn't do anything useful, and it *does* change the type of the object to the SuperClass. That is, after the SuperClass::operator= call this's vtable pointer now points to the vtable for exception, instead of the vtable for CppUnit::Exception. So the assignment operator is broken, and the test correctly detects it and complains. The more interesting question, and I'm not language lawyer enough to answer it definitively, is whether VC++'s exception class's behavior is broken or not. I'd tend to say yes, just based on general anti-MS prejudice, but on the other hand, IIRC, that library was produced by PJ Plauger's Dinkum Software... and I have a fair degree of respect for that man I haven't devoted much effort to researching the correct answer, but a #ifdef _MSC_VER / #endif pair wrapped around that call to SuperClass::operator=() provides symptomic relief of pain. cc me on replies if you want me to see them; I don't subscribe to this list. Use either Joh...@me... (work) or jm...@to... (home). -John. ________________________________________ > The information contained in this transmission is confidential and > proprietary to General Electric Medical Systems. This information is > for use strictly by the intended party. Retransmission of this > correspondence to third parties without the permission of GEMS is > strictly prohibited. If you believe you are not the intended party > for this transmission, you are requested to print this correspondence > and return by U.S. Mail to: GE Medical Systems Information Technologies John Maxwell Software Engineer Voice: (410) 573-6296 FAX: (410) 573-6307 mailto:Joh...@me... snail-mail: 445 Defense Highway, Annapolis MD 21401 Visit us on the Internet: http://www.gemedicalsystems.com |