Ticket #3431 (closed defect: fixed)
[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
- to 'catch' an unexpected value
- to handle 'default' actions, where the cases are for special behavior
- 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
Change History
comment:1 Changed 10 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:4 Changed 10 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].