I have three free functions: F0, F1 and F2. F0 calls F1, which in turn calls F2.
F0 and F2 are C++ functions, where as F1 is a C function. F2 is exposed to F1 via: extern "C"
The code for each of the free functions is as follows:
~~~~ F0.cpp ~~~~
void f0()
{
try
{
f1();
}
catch (...)
{}
}
~~~~ F0.cpp ~~~~
~~~~ F1.c ~~~~
void f1()
{
f2();
}
~~~~ F1.c ~~~~
~~~~ F2.cpp ~~~~
void f2()
{
throw 1
}
~~~~ F2.cpp ~~~~
Question:
Does the exception thrown in f2 progress through f1 and caught correctly in f0?
Or is std::unexpected invoked due to the exception not being handled, or is the whole thing supposed to be undefined behavior? - if so where in the standard does it talk about exception handling in this particular context.
Please note this is not about handling exceptions in C, but rather what happens in the situation where the exception can flow through the C layer (if at all) and be caught in the calling C++ layer - and any resulting side effects etc.