Exceptions in Release mode

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • devprash
    New Member
    • Feb 2010
    • 1

    Exceptions in Release mode

    Hi,

    Mine is a simple program of Try/Catch block. In try I generate exception by one of these(writing to invalid address/ divide by zero). I am catch for all exceptions (ellipse) and logging in catch block. I am using VS 2008 as my IDE.

    In Debug mode it works fine. Catching the exception and graceful exit of program. But if I invoke program built in Release mode, exception is not handled crashing the program.

    Any help would be appriciated.

    Code:
    int _tmain(int argc, _TCHAR* argv[])
    {
    
    	try
    	{
    		printf("About to try\n");
    		int j,i=20;
    		j=i/0;
    		*(char *)j = 0000;
    		printf("Try done\n");
    	}
    
    	catch(...)
    	{
    		printf("Caught Exception\n");
    	}
    
    	printf("Waiting to stop\n");
    	Sleep(5000);
    	return 0;
    }
    Thanks
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You have no throw.

    Microsoft uses structured exceptions only. For example, the C++ throw is just a call to RaiseException.

    Either a) use explicit structured exceptions or b) use explicit try/catch/throw in the C++.

    Comment

    Working...