public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jasonwucj at gmail dot com" <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: Sun, 23 Jun 2013 12:21:00 -0000	[thread overview]
Message-ID: <bug-7652-4-OcPcQ2vBxk@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-7652-4@http.gcc.gnu.org/bugzilla/>

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

Chung-Ju Wu <jasonwucj at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jasonwucj at gmail dot com

--- Comment #19 from Chung-Ju Wu <jasonwucj at gmail dot com> ---
(In reply to David Binderman from comment #17)
> (In reply to Daniel Marjamäki from comment #7)
> > In my experience this type of check is really noisy if there is a warning
> > for every fall through.
> > 
> > I recommend that the warning is written only if the fall through cause
> > redundant or bad behaviour. such as:
> > 
> >     switch (foo) {
> >     case 1: x = y;   // <- redundant assignment
> >     case 2: x = z;
> >     };
> 
> I'd be happy with gcc warning for this kind of problem.
> 
> This specific case should be easier to catch than the 
> general case.


I believe such redundant assignment will be optimized out.


$ gcc --version
gcc (20130621) 4.9.0 20130621 (experimental)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -O2 -S pr7652.c


[pr7652.c]
  1
  2 extern int a;
  3 extern int b;
  4 extern int c;
  5
  6 int
  7 main(int argc, char **argv)
  8 {
  9   int x;
 10
 11   switch (argc)
 12     {
 13     case 1:
 14       x = a;
 15     case 7:
 16       x = b;
 17       break;
 18     default:
 19       x = c;
 20       break;
 21     }
 22
 23   return x;
 24 }


[pr7652.s]
  1         .file   "pr7652.c"
  2         .section        .text.startup,"ax",@progbits
  3         .p2align 4,,15
  4         .globl  main
  5         .type   main, @function
  6 main:
  7 .LFB0:
  8         .cfi_startproc
  9         movl    4(%esp), %eax
 10         cmpl    $1, %eax
 11         je      .L3
 12         cmpl    $7, %eax
 13         je      .L3
 14         movl    c, %eax
 15         ret
 16 .L3:
 17         movl    b, %eax
 18         ret
 19         .cfi_endproc
 20 .LFE0:
 21         .size   main, .-main
 22         .ident  "GCC: (20130621) 4.9.0 20130621 (experimental)"
 23         .section        .note.GNU-stack,"",@progbits


Apparently it is dead code.  IMHO, it may not be a good idea to
have compiler issue a warning everytime when compiler identifies
dead code statements.
>From gcc-bugs-return-424895-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun Jun 23 12:25:40 2013
Return-Path: <gcc-bugs-return-424895-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20466 invoked by alias); 23 Jun 2013 12:25:40 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 20443 invoked by uid 48); 23 Jun 2013 12:25:36 -0000
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/57684] [c++11] Lambda is not convertible to std::function
Date: Sun, 23 Jun 2013 12:25:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: redi at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-57684-4-SJSSHIcDVs@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57684-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57684-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-06/txt/msg01274.txt.bz2
Content-length: 569

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW684

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes, because std::unique_ptr has a special exception that says it can be
instantiated with incomplete types, so that should work OK (like your case
where the static member is a raw pointer, which prevents unordered_map being
instantiated when base<> is instantiated.

I hope for GCC 4.9 we can make unordered_map support incomplete types again, so
the original code would work, but it doesn't support them currently, which is
allowed by the standard.


  parent reply	other threads:[~2013-06-23 12:21 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]
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
     [not found] <bug-7652-1366@http.gcc.gnu.org/bugzilla/>
2010-03-04 20:48 ` pinskia at gcc dot gnu dot org
     [not found] <20020820073602.7652.ac131313@redhat.com>
2004-07-29  9:43 ` brendan at zen dot org

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=bug-7652-4-OcPcQ2vBxk@http.gcc.gnu.org/bugzilla/ \
    --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).