C++: Safe to use longjmp and setjmp?

前端 未结 2 764
情书的邮戳
情书的邮戳 2020-11-27 16:55

Is it safe to use longjmp and setjmp in C++ on linux/gcc with regards to the following?

  1. Exception handling (I\'m not implementing exception handling using long
2条回答
  •  盖世英雄少女心
    2020-11-27 17:44

    It's not specific to Linux or gcc; setjmp / longjmp and C++ don't work too well together if you're using longjmp to leave a context where there are automatic variables with destructors.

    The destructors won't run which may result in a memory leak or other bad behaviour.

提交回复
热议问题