Article View: muc.lists.netbsd.tech.kern
Article #50Re: Do all -current compilers support C23 typed enum syntax?
From: Chris Hanson
Date: Fri, 04 Dec 2026 04:31
Date: Fri, 04 Dec 2026 04:31
35 lines
3737 bytes
3737 bytes
On Dec 3, 2026, at 7:54 PM, Mouse <mouse@Rodents-Montreal.ORG> 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
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID:
<1E9B10E3-8385-4900-89ED-F07C6681A464@eschatologist.net>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mailReferences:
<202612040354.WAA28170@Stone.Rodents-Montreal.ORG> <>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!feeder.erje.net!news2.arglkargh.de!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail From: Chris Hanson <cmhanson@eschatologist.net> Newsgroups: muc.lists.netbsd.tech.kern Subject: Re: Do all -current compilers support C23 typed enum syntax? Date: Thu, 3 Dec 2026 20:31:18 -0800 Organization: Newsgate at muc.de e.V. Sender: tech-kern-owner@NetBSD.org Approved: news-admin@muc.de Distribution: world Message-ID: <1E9B10E3-8385-4900-89ED-F07C6681A464@eschatologist.net> References: <202612040354.WAA28170@Stone.Rodents-Montreal.ORG> <> MIME-Version: 1.0 (Mac OS X Mail 16.0 \(3901.200.71.1.16\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2"; logging-data="51292"; mail-complaints-to="news-admin@muc.de" Authentication-Results: mail.netbsd.org (amavisd-new); dkim=pass (2048-bit key) header.d=eschatologist.net X-Sender-Id: dreamhost|x-authsender|cmhanson@eschatologist.net X-Sender-Id: dreamhost|x-authsender|cmhanson@eschatologist.net X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|cmhanson@eschatologist.net X-MailChannels-Auth-Id: dreamhost X-Whistle-Illustrious: 61d0042a7914a7e3_1796358691941_869659005 X-MC-Loop-Signature: 1796358691941:1507282874 X-MC-Ingress-Time: 1796358691941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eschatologist.net; s=dreamhost; t=1796358691; bh=QLYg0x2rIRoXxxu+dn+crEEdp0dUpVtN314eK+/bJAA=; h=Content-Type:Subject:From:Date:Cc:Content-Transfer-Encoding:To; b=F9ntRN1ZgXtrRug3C0E5VndazxNjHL+s37EskkPdxZhHzXwppielBdZ/aRrqNdMDI Wq8gA4i31TNl6LunHu4DtKYl2q6ktjlqCaHKqfMFaWEvnEc+f5DOR9IQ8l7pBgVTAw /SMHtrvdaBz6d3UyGStOeIfR/zrrGR25u5+UKaZkIECp3A7XMTedzVEbledB+d+1q3 P6QVt9nOHL4cGyvvHCmywFqqV1ys5Cr7J9VnQmWZf9FEv23S0F9bAXH6fX1Ar+vEc0 4ZjnYCOMnY1qMZf6E9p160+zqNEQRVC1sp/cJGuUCqYhUpteguuoofeWqKd0SA5Abo BLYffaGEkJFCA== In-Reply-To: <202612040354.WAA28170@Stone.Rodents-Montreal.ORG> Precedence: bulk X-Newsgate-Id: f02c70b8849f+ X-No-Archive: Yes