locked
First-chance exception warning in output window RRS feed

  • Question

  • When compiling and running the following code in Visual C++ 2010 Express (version 10.0.30319.1) as a simple Win32 console program (starting from an empty project):

    class TestException
    {
    };
    
    
    void DoSomethingElse()
    {
    	throw TestException();
    }
    
    
    void DoSomething()
    {
    	try
    	{
    		DoSomethingElse();
    	}
    	catch (TestException&)
    	{
    		throw;
    	}
    }
    
    
    int main()
    {
    	try
    	{
    		DoSomething();
    	}
    	catch (TestException&)
    	{
    	}
    
    	return 0;
    }
    
    

     

    ...the following is displayed in the Output window, both in Debug and Release:

    First-chance exception at 0x757cb727 in TestException.exe: Microsoft C++ exception: TestException at memory location 0x0016f6cf..
    First-chance exception at 0x757cb727 in TestException.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000..
    

     

    The code otherwise appears to run OK (exited with code 0) - so my question is: why are these warnings being output?  Is there something subtle going wrong in this simple code fragment, or is this just junk output?  And if so, can it be turned off, as it's a little distracting - particularly the apparent NULL address in the rethrow.

    Thanks in advance.

     

    Sunday, April 24, 2011 10:39 PM

Answers

  • First Chance Exception often do not mean there is a problem in the code. after all, you write exception handlers for a reason, and if you are expecting an exception by writing the handling code, the exception's generation should not surprise you.

     



    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    • Marked as answer by Rob Pan Friday, April 29, 2011 8:12 AM
    Sunday, April 24, 2011 11:28 PM