The change below seems to fix this. I believe that the type_info object returned is a
singleton that outlives the object, but I'm not 100% sure of that. Can some C++ expert
confirm this?
==== //depot/project/georgetown/ports/mysql++/build/lib/connection.cpp#1 -
/home/regan/dev/kregan-em-georgetown-ws1/ports/mysql++/build/lib/connection.cpp ====
@@ -314,13 +314,14 @@
bool
Connection::set_option(Option* o)
{
+ const std::type_info& typeInfo = typeid(*o);
error_message_ = driver_->set_option(o);
if (error_message_.empty()) {
return true;
}
else {
if (throw_exceptions()) {
- throw BadOption(error_message_, typeid(*o));
+ throw BadOption(error_message_, typeInfo);
}
return false;
}
--Kevin
________________________________________
From: jonathan.wakely@stripped [jonathan.wakely@stripped] On Behalf Of Jonathan Wakely
[mysql@stripped]
Sent: Saturday, June 13, 2009 3:29 AM
To: Kevin Regan
Cc: plusplus@stripped
Subject: Re: Why dynamic allocation for Option objects?
2009/6/12 Kevin Regan:
> I was taking another look at this issue (please see the code below to following along
> with my issue). If the DBDriver::set_option returns non-empty error string, wouldn't it
> have deleted the objected contained in o that Connection::set_option will call typeid(*o)
> on?
Yes, that's a bug.