Paul Eggert wrote:
> +     quotearg: pacify -Wswitch-enum
> +     * lib/quotearg.c (quotearg_buffer_restyled): Use switch (+E), and
> +     omit default case, to pacify gcc -Wswitch-enum.  This is a good
> +     way to pacify -Wswitch-enum when we don’t want to enumerate
> +     all the enum values.  Omit unnecessary ‘default: break;’s.

This change is problematic for two reasons:

1) It is well-known coding style in C, at least since 1990, to write this:

      switch (some_value)
        {
        case <some possible values>:
          ...
          break;

        default:
          break;
        }

   Having a warning for this widely used style is IMO not useful.
   And rewriting it to

      switch (+some_value)
        {
        case <some possible values>:
          ...
          break;
        }

   deviates from a 35-year-long tradition.

2) Future compiler versions may recognize that (+some_value), although
   being an 'int', is an enumerated value under the hood. Thus a
   warning "cases E1, E2, ... not handled in switch" may appear.

   In other words, the

        default:
          break;

   lines were a witness that the programmer has spent some thought
   regarding the other values. Removing it introduces the question
   whether this omission is intentional or not.

Bruno




Reply via email to