Handling of exception specification violations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

In C++, I would like to take advantage of throw() clauses for their
documentative value (and possible future value if gcc implements
checked exceptions). At the same time however, I want to *usefully*
handle the throwing of unexpected exceptions (where "useful" includes
being able to inspect the exception in question).

Toward this end I have a couple of questions that my Googling has not
helped:

* gcc has an option -fno-enforce-eh-specs which has pretty much the effect
  I would want because it allows for generic top-level catch() statements
  that exit with a useful error message. The man-page says the compiler
  "will still optimize based on the exception specifications". Should I
  interpret this as saying it is *unsafe* to enable this option with
  code that *does* throw unexpected exceptions? If not, is it guaranteed
  to *be* safe?

* providing user-defined behavior for std::unexpected() (as exemplified
  at [1]) would be an alternative aswell - *if* I can obtain a reference
  to the exception during runtime. Is there some way (standard or
  gcc-specific) to do this?

Thank you!

[1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndeepc/html/deep111899.asp

-- 
/ Peter Schuller, InfiDyne Technologies HB

PGP userID: 0xE9758B7D or 'Peter Schuller <peter.schuller@xxxxxxxxxxxx>'
Key retrieval: Send an E-Mail to getpgpkey@xxxxxxxxx
E-Mail: peter.schuller@xxxxxxxxxxxx Web: http://www.scode.org


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux