I have some odd code which needs to call a throwing function in an asm
block and be able to catch the exception thrown. My code looks something like this:
// Throwing Function
void throwing() __asm__("throwing");
void throwing() {
throw "abc";
}
// Assembly function which calls throwing()
void asm_call() {
__asm__ __volatile__ (
"call throwing\n"
);
}
// Main calls the assembly function in a try block
int main() {
try {
asm_call();
} catch (...) {
std::cout << "caught..." << std::endl;
}
return 0;
}
I am unable to get the exception to be caught by main; it always simply terminates when it reaches the throw "abc";
line. I saw a similar question here, and I tried the top answer but it did not work for me. Is it possible to catch the exception which is thrown in the asm_call
?
I'm using x64 Linux with g++ 6.3.0.