|
From: peter koch larsen on 25 Jan 2008 08:38 On 25 Jan., 18:52, Ivan Novick <i...(a)0x4849.net> wrote: > Hi, > > If we have a function that has a local automatic object and then it > throws an exception that is caught somewhere up the call stack ..... > > Does the normal destructor get called for that object? I assume it > has to or else there would be memory leaks everywhere when throwing > exceptions. > > for example: > > void FOO() > { > try > { > BAR(); > } > catch(...) > { > // do some stuff > // according to the C++ standard, can we assume o has been > properly destructed at this point? > } > > } > > void BAR() > { > BigHairyObject o; > throw; > > } I presume you threw something in BAR? If not, your code does not correspond to your question and your object is not guaranteed to be destroyed if I remember correctly. std::terminate will be called and clean-up is implementation defined. Bu otherwise: Yes - of course! If your compiler does forget the clean- up you are not using your compiler in a compliant way. /Peter -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
|
Pages: 1 Prev: BoostCon 2008 Now Open For Registration Next: insufficient contextual information |