Export (0) Print
Expand All

C6318

warning C6318: Ill-defined __try/__except: use of the constant EXCEPTION_CONTINUE_SEARCH or another constant that evaluates to zero in the exception-filter expression. The code in the exception handler block is not executed

This warning indicates that if an exception occurs in the protected block of this structured exception handler, the exception will not be handled because the constant EXCECPTION_CONTINUE_SEARCH is used in the exception filter expression.

This code is equivalent to the protected block without the exception handler block because the handler block is not executed.

Example

The following code generates this warning:

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

void f (char *pch)
{
  __try 
  {
    // assignment might fail
    *pch = 0;
  } 
  __except (EXCEPTION_CONTINUE_SEARCH) // warning 6318
  {
    puts("Exception Occurred");
  }
}

To correct this warning, use the following code:

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

void f (char *pch)
{
  __try 
  {
    // assignment might fail
    *pch = 0;
  } 
  __except( (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION) ?
                EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH )
  {
    puts("Access violation");
  }
} 

See Also

Community Additions

ADD
Show:
© 2014 Microsoft