I realize it's a bit late to jump in here with the path already having been
committed. But I think there's a point that was missed in the discussion.
One reason to do the test as Tom recommended is that the warning probably
indicates that the test as written was just going to be optimized away as
dead code. I think the cast to unsigned is the least likely idiom to be
optimized away whereas any of the formulations based on comparing the enum
with enum labels is quite likely to be.