Re: What the program would behave if an exception is thrown in an environment with exception disabled
"Carl Barron" <cbarron413@adelphia.net> wrote in message
news:271220072104298531%cbarron413@adelphia.net...
In article
<25b0956b-9dbf-43db-96c0-935f4a2982cd@s19g2000prg.googlegroups.com>,
cppcraze <cppcraze@gmail.com> wrote:
Hi Guys,
I work in an Embeded community in which exception has been disabled,
though I recommend using exception, that is out of my control. Now I
have a question: in such a scenario (I mean exception has been
disabled), what if some classes defined by C++ library throw some
exceptions, for example, std::string will handle error and throw
exceptions every time the error happens. Since exception is disabled
in our program, there's no try/catch statements in our program. I want
to know what will happen if exception is thrown in this suitation.
Thanks,
if exceptions are enabled and an exception is throw that is not
caught , std::uncaught_exception() is called and it ultimately calls
abort(). You can provode uncaught_exception() but the standard says
it never returns. The default calls std::abort().
if exceptions are disabled then its compiler dependent what it does
when an exception is thrown , probably just abort() as there is no info
to safely restore anything, since there is no info to safely unwind the
stack destructing C++ classes on the stack as it unwinds.
As far as I know EC++ does not have a standard library but that may have
changed since I looked at EC++ standards.
It does and we've been supplying one to many embedded compiler vendors
for over a decade. You also get an EC++ library as part of our standard
C/C++ library product.
For an essay on how our C++ library handles exceptoins when language
support is not available, see:
http://www.dinkumware.com/manuals/default.aspx?manual=compleat&page=lib_cpp.html#Exceptions
P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]