tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Do all -current compilers support C23 typed enum syntax?
On Dec 3, 2026, at 7:54 PM, Mouse <mouse%Rodents-Montreal.ORG@localhost> wrote:
>
>> The compiler, being very clever, sees that all enumerated values of
>> enum cmd have been covered by the switch, so it helpfully deletes
>> some code it can _prove_ is dead -- this part:
>
>> default:
>> panic("unknown command");
>
> Such a compiler is broken, and I would not hesitate to file a bug
> report against it, if only because nothing prevents recv_cmd from
> returning a cmd whose .name contains a value other than one of the enum
> constants, meaning that code is *not* dead.
The compiler cannot know this, especially if they’re in separate compilation units, without additional information.
> More generally, compilers exist to serve their users, not to
> straitjacket them. If the coder has to work around the compiler, the
> compiler is broken, regardless of what specs it might conform to.
In general, this is not a fruitful line of discussion: Compilers do exist to serve their users, but those users have many different and competing needs, and optimization for both speed and size are among them. And the language specification is ultimately what defines “broken” when it comes to how to best meet those needs.
-- Chris
Home |
Main Index |
Thread Index |
Old Index