问题
I started implementing a try/catch in my program, but when I was testing it, the exceptions were never caught and the program just crashes. Even the simplest use case of a try/catch would fail, i.e
try
{
throw 123;
}
catch (...)
{
cerr << "This line doesn't get hit." << endl;
}
After lots of digging around researching how exceptions work and debugging, I finally found that the issue was because I was linking with specifically -static-libstdc++
which was causing the break. The exceptions work fine when this flag isn't set. After further research I found this bug report, but I can't really figure out what the status is on it. It appears that the issue is still at large, but according to this earlier bug report it seems that there might be a work around according to the comments. Unfortunately I don't understand exactly what all the comments mean and what they did to get it to work if at all outside of building GCC manually (which I'd like to avoid if I can).
Is there a way to resolve this bug while still linking the static standard lib and how would I go about it?
来源:https://stackoverflow.com/questions/50779224/exceptions-not-caught-when-linking-static-libs