Reputation: 56282
Here is a minimum example:
[joel@maison various] (master *)$ cat throw.cpp
#include <iostream>
int main(int argc, char* argv[])
{
throw("pouet pouet");
}
[joel@maison various] (master *)$ ./a.out
terminate called after throwing an instance of 'char const*'
Aborted (core dumped)
Reading the docs, it seems like the default terminate handler is abort()
. I couldn't find anything about triggering a segfault in the abort man page.
Upvotes: 1
Views: 1295
Reputation: 43662
Throwing an exception and not handling it calls abort()
which raises SIGABRT
.
You can verify it with the following
#include <iostream>
#include <stdexcept>
#include <signal.h>
extern "C" void handle_sigabrt(int)
{
std::cout << "Handling and then returning (exiting)" << std::endl;
}
int main()
{
signal(SIGABRT, &handle_sigabrt);
throw("pouet pouet");
}
Upvotes: 7