What does msvc 6 throw when an integer divide by zero occurs?

前端 未结 4 786
陌清茗
陌清茗 2021-01-26 04:10

I have been doing a bit of experimenting, and have discovered that an exception is being thrown, when an integer divide by zero occurs.

#include 

        
相关标签:
4条回答
  • 2021-01-26 04:36

    It's a Windows structured exception, which has nothing to do with C++ - you would get the same exception if it were a C program.

    0 讨论(0)
  • 2021-01-26 04:46

    The result is undefined, you could use __try / __except block to catch the error (structured exception handling). However, why not simply check for the error before your division?

    0 讨论(0)
  • 2021-01-26 04:52

    This article claims to have a way to convert a structured exception to a C++ exception using the _set_se_translator function.

    http://www.codeproject.com/KB/cpp/seexception.aspx

    0 讨论(0)
  • 2021-01-26 04:52

    In msvc6 you can catch it with catch(...) and rethrow it with throw; however since you can't detect exception type that way you're better off doing something else.

    0 讨论(0)
提交回复
热议问题