This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Handling of exception specification violations


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@infidyne.com>'
Key retrieval: Send an E-Mail to getpgpkey@scode.org
E-Mail: peter.schuller@infidyne.com Web: http://www.scode.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]