#206 'throw' operator inside the destructor

open-rejected
nobody
None
5
2011-06-02
2011-06-01
lohotron
No

In file ConsoleClose.cpp, line 69 - destructor uses throw method, which can lead to unexpected results.

Quote:
"You can throw an exception in a destructor, but that exception must not leave the destructor; if a destructor exits by a throw, all kinds of bad things are likely to happen because the basic rules of the standard library and the language itself will be violated. Don't do it."
Bjarne Stroustrup's C++ Style and Technique FAQ

http://www2.research.att.com/~bs/bs_faq2.html

Implement with try..catch blocks.

Discussion

  • Igor Pavlov

    Igor Pavlov - 2011-06-02
    • status: open --> open-rejected
     
  • Igor Pavlov

    Igor Pavlov - 2011-06-02

    I don't think that it's problem.

    Stroustrup probably sees the problem for destructors of objects that are used in vector class.
    But CCtrlHandlerSetter::~CCtrlHandlerSetter is just destructor of simple object.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks