这是编译器资源管理器的人工产物(/bug?)。
SIGABRT
成为
SIGSEGV
:
https://github.com/compiler-explorer/compiler-explorer/issues/5224
在我的计算机上运行它可以:
$ ./example ; echo "Program returned: $?"
Constructor called
Constructor called
Destructor called
terminate called after throwing an instance of 'std::runtime_error'
what(): Exception thrown
Aborted
Program returned: 134
即使在编译器资源管理器上,您也可以处理
SIGABRT
看到它还在那里,只有一个
sigsegov
之后:
https://godbolt.org/z/6dYsP5K5K
std::signal(SIGABRT, [](int) {
std::cout << "Caught SIGABRT\n" << std::flush;
});
std::signal(SIGSEGV, [](int) {
std::cout << "Caught SIGSEGV\n" << std::flush;
std::_Exit(1);
});
编译器资源管理器输出:
Program returned: 1
terminate called after throwing an instance of 'std::runtime_error'
what(): Exception thrown
Constructor called
Constructor called
Destructor called
Caught SIGABRT
Caught SIGSEGV
我的电脑:
$ ./example ; echo "Program returned: $?"
Constructor called
Constructor called
Destructor called
terminate called after throwing an instance of 'std::runtime_error'
what(): Exception thrown
Caught SIGABRT
Aborted
Program returned: 134