public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "brendan at zen dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/7652] -Wswitch-break : Warn if a switch case falls through
Date: Thu, 29 Jul 2004 09:43:00 -0000	[thread overview]
Message-ID: <20040729094303.12212.qmail@sourceware.org> (raw)
In-Reply-To: <20020820073602.7652.ac131313@redhat.com>


------- Additional Comments From brendan at zen dot org  2004-07-29 09:43 -------
An alternative between "warn about all fall-throughs" and "never do it" would 
be quite useful.  If you have 
  case 0: 
  case 1: 
     foo(); 
  default: 
     bar(); 
gcc could warn only on the 'case 1' line, since it will see that there are 
statements between it and the default beneath it without a 'break' intervening.  
The fact that 'case 0' falls into 'case 1' won't be warned, since there are no 
actions between them. 
 
Most of the time, users will have a good reason to do multiple cases, but less 
often will someone want  
	case 0: 
	   bar(i); 
	case 1: 
	   foo(i); 
	   break; 
For those instances, they'll probably not be using -Wswitch-break (defaulting 
to off) anyway.  At any rate, it'll much more common to make the mistake of 
omitting the break, compared to coding it to have statements between cases 
without 'break'.  My opinion, anyway. 
 
B 
 

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652


       reply	other threads:[~2004-07-29  9:43 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20020820073602.7652.ac131313@redhat.com>
2004-07-29  9:43 ` brendan at zen dot org [this message]
     [not found] <bug-7652-1366@http.gcc.gnu.org/bugzilla/>
2010-03-04 20:48 ` pinskia at gcc dot gnu dot org
     [not found] <bug-7652-4@http.gcc.gnu.org/bugzilla/>
2011-02-02  1:04 ` alsuren+gcc at gmail dot com
2011-05-09 14:48 ` barnes.leo at gmail dot com
2011-07-29 13:29 ` daniel.marjamaki at gmail dot com
2012-02-21  1:04 ` eric at brouhaha dot com
2012-02-21  1:14 ` eric at brouhaha dot com
2012-07-14  4:55 ` pinskia at gcc dot gnu.org
2012-07-14 11:54 ` redi at gcc dot gnu.org
2012-07-14 15:15 ` david at doublewise dot net
2012-09-17 22:02 ` alexfh at google dot com
2012-09-18 11:12 ` manu at gcc dot gnu.org
2012-11-26 22:49 ` arthur.j.odwyer at gmail dot com
2012-11-26 23:03 ` arthur.j.odwyer at gmail dot com
2013-06-23  6:44 ` dcb314 at hotmail dot com
2013-06-23 10:38 ` manu at gcc dot gnu.org
2013-06-23 12:21 ` jasonwucj at gmail dot com
2014-02-16 13:18 ` jackie.rosen at hushmail dot com
2014-04-30 15:45 ` michael.chapman at cortus dot com
2014-04-30 16:09 ` mw_triad at users dot sourceforge.net
2014-04-30 16:10 ` manu at gcc dot gnu.org
2014-04-30 16:18 ` fweimer at redhat dot com
2014-04-30 16:23 ` mpolacek at gcc dot gnu.org
2014-04-30 16:35 ` alexfh at google dot com
2014-04-30 16:40 ` manu at gcc dot gnu.org
2014-04-30 17:04 ` mw_triad at users dot sourceforge.net
2014-04-30 17:20 ` michael.chapman at cortus dot com
2014-09-23  7:25 ` m.j.thayer at googlemail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040729094303.12212.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).