C6322

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at C6322.

warning C6322: empty _except block

This message indicates that there is no code in the _except block. As a result, exceptions might go unhandled.

The following code generates this warning:

#include <stdio.h>  
#include <excpt.h>  
#include <windows.h>  
  
void fd(char *pch)  
{  
   __try  
     {  
       // exception rasied if pch is null  
       *pch= 0 ;  
     }  
   __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)  
     {  
     }  
}  

To correct this warning, use the following code:

#include <stdio.h>  
#include <excpt.h>  
#include <windows.h>  
  
void f(char *pch)  
{  
   __try  
     {  
       // exception rasied if pch is null  
      *pch= 0 ;  
     }  
   __except(GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ?   
               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)  
     {  
       // code to handle exception  
       puts("Exception Occurred");     
     }  
}    

try-except Statement

Show: