c++ throw exception, segmentation fault [closed]
I have a short program example.cc as follows:
#include <stdio.h>
int main()
{
try {
throw 999;
} catch (int i) {
printf("Catch i:%d", i);
}
}
If I independently compile this program, it works ok, However, When I link with other object file, it failed, report segmentation fault, I don't why..
Why not look in the debugger and see where the segfault is occurring?
Your minimal sample is fine. I see nothing in it that would cause any problems. It's clear your other object file is at fault.
It's C++, so it's quite possible that static objects inside the other object file are being constructed during startup or destructed during program termination and causing problems.
精彩评论