1

Possible Duplicate:
Exceptions silently caught by Windows, how to handle manually?

I have a small MFC Dialog application and, to my surprise, accessing a NULL pointer was not causing the application to crash! Instead, the application runs normally and only shows a message in the Debug Output window:

First-chance exception at 0x006bef51 in SketchTester.exe: 0xC0000005: Access violation writing location 0x00000000.

When I say "accessing a NULL pointer" I'm refering to something like this:

int * ip = NULL;
(*ip) = 1;

I was expecting that it would show a message box with something like "Unhandled exception at..." (and a Break button to debug it at the problematic code line), as it normaly does in debug, or that it just crashes the application when on release mode. But no, the application just stays there looking good :O

Is this inteded behavior? MFC specific? If so, how can I "turn it off"?

By the way, I'm using Visual Studio 2010.

Community
  • 1
  • 1
amfcosta
  • 1,049
  • 10
  • 21
  • 2
    This can happen when debugging 32-bit on a 64-bit operating system. Don't keep the call stack a secret. – Hans Passant Nov 19 '11 at 01:17
  • @amfcosta do you want to show null pointer exceptions to your user, or are you trying to handle the exception gracefully and VS is swallowing the error? – bakoyaro Nov 19 '11 at 01:20
  • @HansPassant Your right! If I building it in 64bits it behaves as I expected :D – amfcosta Nov 19 '11 at 01:28
  • @bakoyaro I want to show the exceptions. – amfcosta Nov 19 '11 at 01:29
  • Please read the various answers [here](http://stackoverflow.com/questions/2622200/exceptions-silently-caught-by-windows-how-to-handle-manually) - I'm fairly certain you're describing the same behavior, but since you don't specify the context in which you're generating the exception I can't be completely sure. – Shog9 Nov 19 '11 at 02:32

0 Answers0