🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #346

Re: Taming The Switch-Statement

#346
From: Stefan Ram
Date: Tue, 13 Oct 2026 17:28
26 lines
3105 bytes
Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
>   signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
. . .
>Now GCC does /not/ complain about a useless break, unlike bart [1].
>But isn't that a bug in GCC? 

  With "-Wswitch-default", gcc will note that there is no "default".

  One can apply "clang-tidy" to that code to get,

. . .
|main.c:3:55: warning: 'break' will never be executed
|signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
|                                                      ^
|main.c:3:55: warning: This statement is never executed 
|signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
|                                                      ^
|main.c:3:55: note: This statement is never executed
|signed main( void ){ switch( printf( "Hello!\n" ) ) break ; }
|                                                      ^
. . .

  , but "clang-tidy" actually is intended for C++, so one will also
  get some warnings that do not apply to C programs.

Technical Details
Message-ID: <tidy-20261013182719@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-mail
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> <flag-20261012180101@ram.dialup.fu-berlin.de> <M7pzS.141305$wun8.135843@fx13.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: 13 Oct 2026 17:28:26 GMT
Organization: Stefan Ram
Lines: 26
Expires: 1 Sep 2027 11:59:58 GMT
Message-ID: <tidy-20261013182719@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> <flag-20261012180101@ram.dialup.fu-berlin.de> <M7pzS.141305$wun8.135843@fx13.ams4>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de rUtyMcsrTs4DLG/wlvWbkwRxsT0ZRzsR/eL0hej7jTY78G
Cancel-Lock: sha1:LMRERw5IGbGE/ha4iePaE72mQ3o= sha256:rEwp7dRZUwPiZxOfJuAABz4/oKvvnUv+VRHdyrUg6x4=
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