www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - What is this?

reply bobef <bobef abv_nospam.bg> writes:
Hey guys,

do you know what is this and could cause it?
"An exception was thrown while finalizing an instance of class whatever". 
Oct 22 2007
parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
bobef wrote:

 Hey guys,
 
 do you know what is this and could cause it?
 "An exception was thrown while finalizing an instance of class whatever".

I believe it means an exception is thrown in a destructor or similar (and afaik a Tango feature). -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango
Oct 22 2007
parent reply Sean Kelly <sean f4.ca> writes:
Lars Ivar Igesund wrote:
 bobef wrote:
 
 Hey guys,

 do you know what is this and could cause it?
 "An exception was thrown while finalizing an instance of class whatever".

I believe it means an exception is thrown in a destructor or similar (and afaik a Tango feature).

This is exactly right. Throwing an exception from a dtor constitutes a programming error and Tango attempts to discourage this by handling it in much the same way as an assertion failure. The exception is wrapped in a FinalizeException before passing it up the stack. This is one of the few (or perhaps the only) place in the Tango runtime where I decided to actually restrict legal programming behavior. One reason for this is that currently, multiple in-flight exceptions will not terminate a D application--one will simply replace the other (this could be changed in the runtime as well but I haven't done so yet). Another is that it's nearly impossible to write correct code if dtors are allowed to throw. C++ uses the no-throw spec for dtors in the STL for this reason, and I believe that "encouraging" the same behavior in user code is worthwhile. Sean
Oct 22 2007
parent bobef <bobef abv_nospam.bg> writes:
Sean Kelly Wrote:

 Lars Ivar Igesund wrote:
 bobef wrote:
 
 Hey guys,

 do you know what is this and could cause it?
 "An exception was thrown while finalizing an instance of class whatever".

I believe it means an exception is thrown in a destructor or similar (and afaik a Tango feature).

This is exactly right. Throwing an exception from a dtor constitutes a programming error and Tango attempts to discourage this by handling it in much the same way as an assertion failure. The exception is wrapped in a FinalizeException before passing it up the stack. This is one of the few (or perhaps the only) place in the Tango runtime where I decided to actually restrict legal programming behavior. One reason for this is that currently, multiple in-flight exceptions will not terminate a D application--one will simply replace the other (this could be changed in the runtime as well but I haven't done so yet). Another is that it's nearly impossible to write correct code if dtors are allowed to throw. C++ uses the no-throw spec for dtors in the STL for this reason, and I believe that "encouraging" the same behavior in user code is worthwhile. Sean

Thanks.
Oct 23 2007