On 2/4/25 02:57, Bruno Haible wrote:

It's a maintainability issue: Assume that in the future the enum definition
gets extended. When the programmer had omitted the 'default: break;'
clause, they are now *relying* on gcc's -Wswitch-enum to tell them when to
adapt the code. Whereas with the 'default: break;' clause, the code
will at least do something reasonable (maybe not fully correct) without
programmer intervention.

I have the opposite take on maintainability. I want to be warned, and I don't want a program to do something randomish. That is, I prefer static checking to dynamic checking, when static checking is feasible, which is the case here.


with yesterday's patches, you can now ignore the warnings.

I don't want to ignore the warnings. I want to pay attention to them because they have a reasonable probability of helping to improve the code. The warnings did that just now for printf-args.c, by helping us distinguish between the TYPE_NONE case and the "should not happen" case. Before, that distinction was not clear to the ordinary reader or to the compiler; now it is.


I'm adding this patch to refine the 'default:' case behaviour.

Thanks. For situations like these I prefer "default: unreachable ();" to "default: abort ();", as "unreachable ()" lets the builder decide whether to abort or optimize; but it's no big deal.


Reply via email to