17.7.2 Arithmetic Type Conversion

Here are some ways in C to convert an arithmetic expression e to a possibly different arithmetic type t.

INT_PROMOTE (e) is an expression with the same value as the arithmetic expression e but with e’s type after any integer promotion. It behaves like +e.

In the following example, using INT_PROMOTE pacifies GCC’s -Wswitch-enum option, and may help human readers see what is going on even if they are not expert in C’s integer promotion rules and might be confused by the simpler switch (+v).

enum { A = 1, B, C, D, E } v = ...;
switch (INT_PROMOTE (v))
  {
    case A: case C:
      return true;
    default:
      /* Handle all other cases,
         even cases like v == 0.  */
      return false;
  }