public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53960] New: Add warning about implicit fallthrough in switch
@ 2012-07-14  4:35 david at doublewise dot net
  2012-07-14  4:53 ` [Bug c++/53960] " pinskia at gcc dot gnu.org
  2012-07-14  4:54 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: david at doublewise dot net @ 2012-07-14  4:35 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53960
           Summary: Add warning about implicit fallthrough in switch
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: david@doublewise.net


A helpful warning that should catch real bugs would be to warn for cases of
implicit fallthrough in a switch statement in C / C++. This warning is
currently implemented in clang. However, I feel that their implementation is
flawed, and we can do it a little better. It is idiomatic C / C++ to do
something like this, which should not be warned about:

    switch(n) {
        case 0:
        case 1:    // Implicit fallthrough, but obviously intended
            do_something();
            break;
        default:
            break;
    }

Perhaps we should add two sets of warnings? Something like
-Wimplicit-fall-through and -Wimplicit-fall-through-empty-case? The second
warning would be identical to the clang warning, which warns whenever a case in
a switch does not end in something like break or return, while the first
warning is the (much more useful) warning only if a case is not completely
empty.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/53960] Add warning about implicit fallthrough in switch
  2012-07-14  4:35 [Bug c++/53960] New: Add warning about implicit fallthrough in switch david at doublewise dot net
@ 2012-07-14  4:53 ` pinskia at gcc dot gnu.org
  2012-07-14  4:54 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-07-14  4:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-07-14 04:52:49 UTC ---
I have seen this request before ...


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/53960] Add warning about implicit fallthrough in switch
  2012-07-14  4:35 [Bug c++/53960] New: Add warning about implicit fallthrough in switch david at doublewise dot net
  2012-07-14  4:53 ` [Bug c++/53960] " pinskia at gcc dot gnu.org
@ 2012-07-14  4:54 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-07-14  4:54 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-07-14 04:54:03 UTC ---
Yep, an old bug report 7652.

*** This bug has been marked as a duplicate of bug 7652 ***


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-14  4:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-14  4:35 [Bug c++/53960] New: Add warning about implicit fallthrough in switch david at doublewise dot net
2012-07-14  4:53 ` [Bug c++/53960] " pinskia at gcc dot gnu.org
2012-07-14  4:54 ` pinskia at gcc dot gnu.org

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).