Compiler Warning (level 4) C4571 (original) (raw)

In this article

Informational: catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught

Remarks

C4571 is generated for every catch(...) block when you specify the /EHs compiler option.

When you specify the /EHs compiler option, catch(...) blocks don't catch structured exceptions. (Divide by zero, or null pointer exceptions, for example.) A catch(...) block only catches explicitly thrown C++ exceptions. For more information, see Exception Handling.

This warning is off by default. Turn this warning on to ensure that when you compile with /EHs your catch (...) blocks don't catch structured exceptions. For more information, see Compiler warnings that are off by default.

You can resolve C4571 in one of the following ways:

Example

The following example generates C4571.

// C4571.cpp
// compile with: /EHs /W4 /c
#pragma warning(default : 4571)
int main() {
   try {
      int i = 0, j = 1;
      j /= i;   // this will throw a SE (divide by zero)
   }
   catch(...) {}   // C4571 warning
}

Feedback

Was this page helpful?

No

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?