intermixing c++ exception handling and SEH (windows)

前端 未结 3 1178
不知归路
不知归路 2021-02-10 00:25

I have a function in which I call getaddrinfo() to get an sockaddr* which targets memory is allocated by the system. As many may know, you need to call

3条回答
  •  没有蜡笔的小新
    2021-02-10 01:09

    catch(int& X)
    {
        std::cout << "caught a X" << std::endl;
    }
    

    That doesn't catch an X, it catches an int&. Since there is no matching catch block, the exception is uncaught, stack unwinding doesn't occur, and __finally handlers don't run.

    You can put catch (...) in your thread entrypoint (which is main() for the primary thread) in order to make sure that stack unwinding occurs, although some exceptions are unrecoverable, that's never true of a C++ exception.

提交回复
热议问题