Skip to content

Latest commit

 

History

History
37 lines (29 loc) · 1.35 KB

compiler-warning-level-4-c4062.md

File metadata and controls

37 lines (29 loc) · 1.35 KB
description title ms.date f1_keywords helpviewer_keywords
Learn more about: Compiler Warning (level 4, off) C4062
Compiler Warning (level 4, off) C4062
04/05/2019
C4062
C4062

Compiler Warning (level 4, off) C4062

enumerator 'identifier' in switch of enum 'enumeration' is not handled

The enumerator identifier doesn't have a case handler associated with it in a switch statement, and there's no default label that can catch it. The missing case may be an oversight, and is a potential error in your code. For a related warning on unused enumerators in switch statements that have a default case, see C4061.

This warning is off by default. For more information about how to enable warnings that are off by default, see Compiler Warnings That Are Off by Default.

Example

The following sample generates C4062, and shows how to fix it:

// C4062.cpp
// compile with: /EHsc /W4
#pragma warning(default : 4062)
enum E { a, b, c };
void func ( E e ) {
   switch(e) {
      case a:
      case b:
   // case c:  // to fix, uncomment this line
      break;   // no default label
   }   // C4062, enumerator 'c' not handled
}

See also

Compiler Warning (level 4) C4061