dimanche 19 avril 2015

C++ try-catch block doesn't catch hardware exception

I'm examining hardware and software exceptions in visual studio 2013. I know that I can catch hardware exceptions by setting 'Enable C++ Exceptions' option to /EHa (Yes with SEH Exceptions). I'm trying to catch the following exceptions:


EXCEPTION_ARRAY_BOUNDS_EXCEEDED - didn't catch


EXCEPTION_ACCESS_VIOLATION - caught


EXCEPTION_INT_OVERFLOW - didn't catch


EXCEPTION_INT_DIVIDE_BY_ZERO - caught


This is an example of code.



try {
a = std::numeric_limits<int>::max();
a += 5;
}
catch (...){

std::cout << "EXCEPTION_INT_OVERFLOW Exception Caught" << std::endl;
exit(1);
}

try {
int h = 0;
b = b / h;
}
catch (...){

std::cout << "EXCEPTION_INT_DIVIDE_BY_ZERO Exception Caught" << std::endl;
exit(1);
}


It catches only divide by zero exception. Is this dependent of processor, or there is something else? One more little question, is there any difference between debug and release builds?


Thanks a lot.


Aucun commentaire:

Enregistrer un commentaire