Ark*_*ady 8 c++ linux exception
我在库中有这个方法:
#include <stdexcept>
mytype* myfunc()
{
throw std::runtime_error("is uncatchable");
}
Run Code Online (Sandbox Code Playgroud)
这是int main()链接库的可执行过程.
try { myfunc(); }
catch(std::exception const& ex) { std::cout << "handled: " << ex.what() << std::endl; }
catch(...) { std::cout << "something else..." << std::endl; }
Run Code Online (Sandbox Code Playgroud)
这是输出:
terminate called after throwing an instance of 'std::runtime_error'
what(): is uncatchable
Abort (core dumped)
Run Code Online (Sandbox Code Playgroud)
问题:为什么异常没有被捕获?
我不管理我的编译器标志(icc-11.X),OS也不在我的控制之下.
编译器标志列表:
-DLINUX -DLINUX_X64 -DGNU_SOURCE -fPIC -Wcheck -Wshadow -Wdeprecated -Wreturn-type -Wcomment -Wmissing-prototypes -Wp64 -Drcsid="__attribute__((used)) rcsid"
-D__EXTENSIONS__ -D__STD_C__ -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -DNDEBUG
Run Code Online (Sandbox Code Playgroud)
__EXCEPTIONS 被定义为.
可能存在导致这种情况的Linux设置吗?
可能存在导致这种情况的编译器设置吗?