Hello,

I'm posting this message to alert the SOCI users to a *potential* change in
the next version of the C++ standard of the language that, if adoprted,
would cause unexpected program termination in unchanged programs compiled
with a C++0x compiler.

During recent ISO C++ committee meeetings about the next version of the C++
standard there has been some discussion about destructors that throw
exceptions.

Note that this *already* causes problems in C++03 as any exception thrown
from a destructor called during stack unwinding will cause the program to
end (via a call to the std::terminate() function); the general guidance is
to avoid exceptions propagating out of destructors.

However, there is a proposal to give destructors (by default) the (new)
exception specification of "nothrow(true)".  This would have the effect
that, by default, any destructor that throws will cause program termination.

The SOCI library is a counter argument to such a proposal since SQL
exceptions *are* thrown by the destructor of the temporary object created by
the "<<" operator.

The following code:

 sql<<  "select name, salary from persons where id = "<<  id,
         into(name), into(salary);

invokes the actual execution of the database query in the destructor 
of the soci object returned from operator<<  at the closing semicolon.
Any SQL exception will be thrown *from the destructor*.

So, *if* this proposal goes ahead, then any program using the existing
codebase would find the program terminating when a SQL exception was thrown
and the SOCI code would have to be changed, for compilation under C++0x, to
allow the destructor of the temporary object to throw.

The question is still in open discussion in the committee and the final
decision is not clear, but I felt that a 'heads up' to this channel would be
useful.

Regards,
Roger.


------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to