Re: Is it possible to catch an exception raised by a member variable?
On Sep 28, 4:33 pm, "Chris ( Val )" <chris...@gmail.com> wrote:
On Sep 28, 10:52 pm, Pete Becker <p...@versatilecoding.com> wrote:
On 2007-09-28 05:30:31 -0400, "Chris ( Val )" <chris...@gmail.com> said:
B = new Base( "Oracle.driver.bar" );
catch( const std::exception& e )
I am interested to hear your, and the groups
thoughts on the validity of such a construct.
It really doesn't show anything. Replace the "B = new ..." with "throw
std::exception();" and you'll probably get the same result. Calling
member functions on uninitialized pointers produces undefined behavior,
so anything you see is as valid as anything else.
I tried a non pointer version, and the results are the same.
Could you show it. If you replace the line with new Base...,
with something like:
Base b( "Oracle.driver.bar" ) ;
then b isn't even in scope in the catch block, and cannot be
What I am curious about is at what point does the object actually
cease to exist? (which scope?)
Which object. The object whose destructor exits via an
exception never begins to exist, so the question of when it
ceases to exist is moot.
Is it not possible for it to even be partially constucted to
report such information back?
No. Or rather, it can put information in the exception, which
will propagate up. But if a constructor exits because of an
exception, all fully constructed sub-objects are immediately
destructed, and if the constructor was called as part of a new
expression, the allocated memory is immediately freed.
James Kanze (GABI Software) email:email@example.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34