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.

Example

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");   
     }
}  

See Also

Reference

try-except Statement