开发者

c++ throw exception, segmentation fault [closed]

开发者 https://www.devze.com 2023-02-20 15:34 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For hel开发者_
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For hel开发者_StackOverflowp clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号