On Fri, Jul 31, 2009 at 02:43:38PM +0200, Jens Vollinga wrote:
Alexei Sheplyakov schrieb:
I'm afraid this code is a bit dangerous.
Suppose reader->second corresponds to the serial of some (GiNaC::)function (and not a pointer to a C++ function). ret = GiNaC::function(...) calls eval(), and it might throw an exception. We catch the exception and dereference ->second => oops...
you are right. I fixed it now. Thanks!
I don't think the new variant is any different. 69 // dirty hack to distinguish between serial numbers of functions and real 70 // pointers. 71 try { 72 GiNaC::function f(reinterpret_cast<unsigned>(reader->second), args); 73 return f; eval() is still called here. The compiler has to call ex::ex(const basic&) ctor in order to convert the value being returned to the correct type (ex). That ctor calls ex::construct_from_basic(const basic&), and it calls eval() (which might throw an exception, and so on). Best regards, Alexei