Closed ryandesign closed 2 months ago
Although now I learn that if you do add a default
to a switch
where you've handled all the enumeration cases, clang (if using -Weverything
or just -Wcovered-switch-default
) will say warning: default label in switch which covers all enumeration values
. And there is a concern that if you add a default
now and add more values to the enumeration later, you will not be warned that you haven't handled them separately in the switch
. So perhaps just a return
at the end of the function is the answer.
Building the latest code from the repo on Linux with cmake (which uses
-Wall -Wextra
) and g++ 11.4.0, I get these warnings:I think this is because although you've handled all the enumeration cases, you haven't handled the hypothetical case of a some other integer being passed to these functions. While that situation probably doesn't arise, the warning could be silenced by adding a
default
case. In other functions I've seen you use:https://github.com/TomHarte/CLK/blob/018f0e097fabe264695561e4e18cb46297cc083b/InstructionSets/M50740/Parser.hpp#L68