Article View: comp.lang.c
Article #271Re: Taming The Switch-Statement
From: Stefan Ram
Date: Mon, 12 Oct 2026 17:02
Date: Mon, 12 Oct 2026 17:02
15 lines
2522 bytes
2522 bytes
Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
>Not to me. A giant red flag would be something akin to
> switch ( foo ) printf( "Hello, bart\n" ) ;
>where the printf() never gets called.
GCC also flags it:
main.c: In function 'main':
main.c:3:30: warning: statement will never be executed [-Wswitch-unreachable]
3 | int main( void ){ switch( 0 )printf( "Hello!\n" ); }
| ^~~~~~~~~~~~~~~~~~~~
. I use, " . . . -pedantic . . . -Wall -W -Wextra -Wpedantic . . .".
Technical Details
Message-ID:
<flag-20261012180101@ram.dialup.fu-berlin.de>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!fu-berlin.de!uni-berlin.de!not-for-mailReferences:
<119qf6l$2rmg3$1@dont-email.me> <11ac0mi$19kfd$1@dont-email.me> <11ac2jv$1a84t$1@dont-email.me> <11ac783$1bkuo$1@kst.eternal-september.org> <11ad5eq$1l8hg$1@dont-email.me> <11aehqg$24k8m$3@kst.eternal-september.org> <11aenps$27sq7$1@dont-email.me> <11aetqv$29hmu$1@kst.eternal-september.org> <11afrfq$2j2o6$1@dont-email.me> <11agtkb$30q22$1@kst.eternal-september.org> <11ah16h$320sj$2@dont-email.me> <11ahqpu$38ir0$3@dont-email.me> <11aidi3$3gbu4$1@dont-email.me> <td6zS.60653$jNL6.31326@fx12.iad> <11aivdn$3nvmh$1@dont-email.me> <dI7zS.10223$AEj4.10181@fx17.ams4>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.c
Subject: Re: Taming The Switch-Statement
Date: 12 Oct 2026 17:02:32 GMT
Organization: Stefan Ram
Lines: 15
Expires: 1 Sep 2027 11:59:58 GMT
Message-ID: <flag-20261012180101@ram.dialup.fu-berlin.de>
References: <119qf6l$2rmg3$1@dont-email.me> <11ac0mi$19kfd$1@dont-email.me> <11ac2jv$1a84t$1@dont-email.me> <11ac783$1bkuo$1@kst.eternal-september.org> <11ad5eq$1l8hg$1@dont-email.me> <11aehqg$24k8m$3@kst.eternal-september.org> <11aenps$27sq7$1@dont-email.me> <11aetqv$29hmu$1@kst.eternal-september.org> <11afrfq$2j2o6$1@dont-email.me> <11agtkb$30q22$1@kst.eternal-september.org> <11ah16h$320sj$2@dont-email.me> <11ahqpu$38ir0$3@dont-email.me> <11aidi3$3gbu4$1@dont-email.me> <td6zS.60653$jNL6.31326@fx12.iad> <11aivdn$3nvmh$1@dont-email.me> <dI7zS.10223$AEj4.10181@fx17.ams4>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de 8rseLx4HzAvYsVvfg0j1jQgcQsu/G0HZRaMuSfVZ5ayrmm
Cancel-Lock: sha1:J5hqxio6mH1KeEJJd/UhDXELYVw= sha256:0/0BeFdKxwKWudItrmIayfKbmVfMSnxOt0BPYYHs8XY=
X-Copyright: (C) Copyright 2026 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en