Why after enabling floating point exceptions I got multiple traps error

后端 未结 2 2016
我寻月下人不归
我寻月下人不归 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: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)

提交回复
热议问题