Share via


C6310

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

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.

Example

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