Ticket #3431 (closed defect: fixed)

Opened 9 years ago

Last modified 9 years ago

[patch] introduce -Wswitch-default check

Reported by: and Owned by:
Priority: minor Milestone: 4.8.15
Component: mc-core Version: master
Keywords: Cc:
Blocked By: Blocking:
Branch state: no branch Votes for changeset: committed-master

Description

introduce -Wswitch-default check because switch cases should almost always have a default case

  1. to 'catch' an unexpected value
  2. to handle 'default' actions, where the cases are for special behavior
  3. to show someone reading your code that you've covered that case

please cross check for default stub case and add code comment at default case

Attachments

mc-indroduce-wswitch-default-check.patch (24.2 KB) - added by and 9 years ago.

Change History

Changed 9 years ago by and

comment:1 Changed 9 years ago by ossi

case 1. is usually counterproductive: by adding default everywhere, you defeat the compiler's ability to warn about uncovered cases (i.e., the point of the warning you are enabling), which is of particular importance when new cases are added in the future. of course, that works only if enums are used instead of ints+#defines in the first place.
from this follows that 3. is kinda a weird thing to say.
i agree with 2.

so this patch should be looked at with a very critical eye.

comment:2 Changed 9 years ago by andrew_b

  • Blocked By 3420 added

comment:3 Changed 9 years ago by andrew_b

  • Blocked By 3420 removed

comment:4 Changed 9 years ago by andrew_b

  • Status changed from new to closed
  • Votes for changeset set to committed-master
  • Resolution set to fixed
  • Milestone changed from Future Releases to 4.8.15

Thanks!
Applied with some modification as [2789e6e390e2eefeb6e9e0d18f243fe4203441ba].

Note: See TracTickets for help on using tickets.