Why after enabling floating point exceptions I got multiple traps error

后端 未结 2 1996
我寻月下人不归
我寻月下人不归 2021-02-11 09:46

Environment Windows 10 with MSVC2015 professional, compile with /EHa

What I\'m doing: enabling floating point exception to be able to catch exceptions when some bad thin

相关标签:
2条回答
  • 2021-02-11 10:00

    I found answer on MSDN, problem with x86 platform, on x64 we can get correct exception code from thread context register see ref - // https://social.msdn.microsoft.com/Forums/en-US/48f63378-19be-413f-88a5-0f24aa72d3c8/the-exceptions-statusfloatmultipletraps-and-statusfloatmultiplefaults-is-needed-in-more

    0 讨论(0)
  • 2021-02-11 10:07

    There are several things to know about FP exceptions:

    • controlfp's flags mask (i.e. disable) the exceptions you set, not enable them. So to enable only division by 0, you'd need set everything but in EM_ZERODIVIDE in the arguments
    • exceptions in SSE code are not affected by controlfp, you'd need to use _mm_setctr (so if you have SSE/AVX enabled in the compiler settings, most of your code will likely use SSE, even scalar)
    • if an exception happened when it was masked, it'll break if you enable it later (unless some code clears the status word)
    0 讨论(0)
提交回复
热议问题