S
S
sitev_ru2016-05-31 11:02:19
C++ / C#
sitev_ru, 2016-05-31 11:02:19

Try catch processing. What am I doing wrong?

I can't catch an exception and, accordingly, debug a C++ program...

try {
    int a = 1, b = 0;
    int c = a / b; // в данном случае имитирую exception для примера
  }
  catch (...) {
    int a = 1;
  }

Previously, I set a breakpoint in catch and could catch the exception. Why is it not working now. Maybe it's the IDE settings? I'm using Visual Studio 2013

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
Xano, 2016-05-31
@Xano

division by 0 is not an exception, but an iron level error. You cannot intercept, you can process it by including the csignal header file and setting the handler for SIGFPE.
Specifically, the studio may have its own bike for intercepting such errors and converting them to an exception, but I won’t tell you where to set it up, it might be worth digging into Debug-> Exceptions

A
Alec Onim, 2016-05-31
@Caitiff_One

Do you catch that type of exception?

A
Armenian Radio, 2016-05-31
@gbg

Perhaps the optimizer threw out code that does nothing.
put something in the exception handler with a side effect, like cout << "FAULT!" <<endl;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question