Consider the following code:
try {
int *i = NULL;
i[100] = 20;
catch (...) {
std::cout << "Exception Caught";
}
When running this code, it crashes (obviously, accessing a NULL pointer). Although, in Debug mode, Visual Studio states about an Uncaught exception, regarding write access violation.. also understandable.
I expected an exception to be caught here, but none is.
My conclusion is that no exception is being thrown.
So why is VS alerting about an uncaught exception ?
This question all started when I wanted to protect myself from code by another programmer, and wanted to wrap the calls to his functions with try-catch, assuming that he might be doing some access violations. But if I can only catch exceptions that are expicitily thrown, I'm pretty screwed. The only other explanation I may have is that this is because of some kind of Project or compiler configuration. I ran this in a new C++ Console Application is VS2005.
Thanks