Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VC7.1 std::exception assignment operator bug (crash) a known issue?

3 views
Skip to first unread message

Niels Dekker - no return address

unread,
Jun 2, 2008, 8:41:53 AM6/2/08
to
The assignment operator of the VC7.1 SP1 edition of std::exception appears to
have a major bug. When it is called on an object of a class derived from
std::exception, it might corrupt the virtual table of the object. When it
does, a subsequent virtual function call causes a crash. For example:

//////////////////////////////////////////////////
#include <exception>

class MyException : public std::exception
{
public:
int NonVirtualFun()
{
return VirtualFun();
}

virtual int VirtualFun()
{
return 0;
}
};

int main()
{
MyException a, b;
a = b; // Internally calls std::exception::operator=.
return a.NonVirtualFun(); // MSVC 2003 crash!
}
//////////////////////////////////////////////////

Is this a known issue? Fortunately I could not reproduce the crash on later
versions of Visual C++. So is it fixed? I couldn't find a bug report on the
issue.

Originally I thought that it had to do with the bug reported by Jouni
Kiviniemi at
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=328570
"Memory leak on std::exception assignment operator", but that one doesn't
mention any crash.


Kind regards,

--
Niels Dekker
http://www.xs4all.nl/~nd/dekkerware
Scientific programmer at LKEB, Leiden University Medical Center


0 new messages