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,378 of 33,346   
   Wil Evers to Dave Abrahams   
   Re: Will we ever be able to throw from a   
   06 Jun 12 22:28:43   
   
   From: bouncer@dev.null   
      
   Dave Abrahams wrote:   
      
   > on Tue Jun 05 2012, Wil Evers  wrote:   
   >   
   >> Dave Abrahams wrote:   
   >>   
   >>> So in your view, there is a substantial difference between:   
   >>>   
   >>>   struct C { C(){throw 1;} };   
   >>>   void f()   
   >>>   {   
   >>>       C x;   
   >>>       ...   
   >>>   }   
   >>>   
   >>> and   
   >>>   
   >>>   struct D { ~D(){throw 1;} };   
   >>>   void f()   
   >>>   {   
   >>>       {D x;}   
   >>>       ...   
   >>>   }   
   >>>   
   >>> in terms of their meaningfulness or handle-ability?  I'd be   
   >>> interested in your explanation, if so.  It seems to me that as the   
   >>> user of f(), I don't care whether the exception came from C's   
   >>> constructor or D's destructor.   
   >>   
   >> In C++11, in the first example, an exception will escape from f(),   
   >> while in the second example, the terminate handler gets called.  To   
   >> me, that sounds like a pretty substantial difference.   
   >   
   > I think you are mistaken.  Both programs have the same behavior.   
      
   As far as I know, in C++11, destructors are noexcept by default, so D is   
   equivalent to   
      
    struct D { ~D() noexcept { throw 1; } };   
      
   The 'throw 1;' breaks the promise not to throw; hence the call to the   
   terminate handler.   
      
   Regards,   
      
   - Wil   
      
      
   --   
         [ 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