Export (0) Print
Expand All
Expand Minimize

C6310

warning C6310: illegal constant in exception filter can cause unexpected behavior

This message indicates that an illegal constant was detected in the filter expression of a structured exception handler. The constants defined for use in the filter expression of a structured exception handler are:

  • EXCEPTION_CONTINUE_EXECUTION

  • EXCEPTION_CONTINUE_SEARCH

  • EXCEPTION_EXECUTE_HANDLER

These values are defined in the runtime header file excpt.h.

Using a constant that is not in the preceding list can cause unexpected behavior.

The following code generates this warning:

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

BOOL LimitExceeded();

void fd( )
{
  __try 
  {
    if (LimitExceeded()) 
    {
      RaiseException(EXCEPTION_ACCESS_VIOLATION,0,0,0);
    }
    else
    {
      // code 
    }
  } 
  __except (EXCEPTION_ACCESS_VIOLATION)
  {
    puts("Exception Occurred");
  }
}

To correct this warning, use the following code:

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

BOOL LimitExceeded();

void fd( )
{
  __try 
  {
    if (LimitExceeded()) 
    {
      RaiseException(EXCEPTION_ACCESS_VIOLATION,0,0,0);
    }
    else
    {
      // code 
    }
  } 
  __except (GetExceptionCode()==EXCEPTION_ACCESS_VIOLATION ? 
               EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
  {
    puts("Exception Occurred");
  }
}
Show:
© 2014 Microsoft