Warning C6322

Empty __except block

Remarks

This message indicates that there's no code in the __except block. As a result, exceptions might go unhandled.

Code analysis name: EXCEPT_BLOCK_EMPTY

Example

The following code generates this warning:

#include <stdio.h>
#include <excpt.h>
#include <windows.h>

void fd(char *pch)
{
   __try
   {
     // exception raised 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 raised 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

try-except Statement