home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,412 of 33,346   
   DeMarcus to sunseraphic   
   Re: Will we ever be able to throw from a   
   15 Jun 12 11:37:35   
   
   From: use_my_alias_here@hotmail.com   
      
   On 06/15/2012 01:45 AM, sunseraphic wrote:   
   > Sorry for short reply :p   
   >   
   > In RAII/RRID, destructor plays a role of "finally block" as in the   
   > other language.   
   >   
   > How do you think about to throw another exception in the finally   
   > block? :)   
      
   I'm not too familiar with finally blocks but I guess that to be able   
   to throw from them you would need some kind of exception bulking (see   
   below).   
      
   > You've pointed out some actual problems.   
   >   
   > But to throw an execption in destructor is not the way to solve   
   > them.   
      
   No, you are correct. I have always had the feeling that throwing from   
   a destructor is a bad idea, but I've never seen a proof that it will   
   be impossible even with future C++. Therefore I tried to state such   
   "proof".   
      
   With the input from the people here I managed to come up with an even   
   better "proof" (at least in regards to convince myself). It's the   
   following.   
      
   We can't throw from destructors unless we are able to bulk up all   
   exceptions thrown from all the destructors until the first catch. Even   
   if that was possible we would need to choose between   
      
   1. Just running each destructor until it throws and then proceed with   
   the next destructor.   
      
   2. Running the whole destructor even if it throws (bulking it).   
      
   In 1. we would likely have resource leaks. In 2. we would likely have   
   undetermined behavior.   
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca