https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71025
Bug ID: 71025 Summary: std::call_once aborts instead of propagating an exception (AIX 6.1) Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: vfried at opentext dot com Target Milestone: --- When an exception is thrown inside a function called from std::call_once, the process is aborted. The exception should be propagated outside std::call_once. #include <stdio.h> #include <mutex> #include <stdexcept> int main() { static std::once_flag flag; printf( "start\n" ); try { std::call_once( flag, [&]() { throw std::runtime_error("thrown from once"); } ); } catch ( std::runtime_error const& exc ) { printf( "%s\n", exc.what() ); } printf( "end\n" ); return 0; } bea@stbldap02:~/samples$ g++ -std=c++14 -pthread std_call_once_exception.cxx bea@stbldap02:~/samples$ ./a.out start terminate called after throwing an instance of 'std::runtime_error' what(): thrown from once IOT/Abort trap (core dumped) BTW: the system on which I tested it should be the same as in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67478