Re: What should happen with an exception in mixed C/C++ code?
rwillmer@gmail.com wrote:
Imagine this scenario:
Function A is C++ code
Function B is C code which takes a callback function
Function C is C++ code
A calls B, passing C as the callback.
C generates an exception.
What is the correct behaviour?
Whatever the implementation says it is. As far as the standard
is concerned, it is undefined behavior, but as a QoI issue, I
would expect an implementation to define it, in so far as
possible.
i) Exception propagates to B, which terminates the program because it
doesn't understand exceptions.
ii) Exception propagates to A and can be handled as normal.
iii) Indeterminate
In so far as possible, I would expect an implementation to try
to achieve ii. In practice, this isn't always feasable. Read
the documentation of your compiler (and if you need to be
portable, don't do it).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]