Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
C6318
Collapse the table of content
Expand the table of content

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.

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");
  }
} 
Show:
© 2015 Microsoft