This is the mail archive of the
mailing list for the GCC project.
Re: Implement -Wswitch-fallthrough
- From: Marek Polacek <polacek at redhat dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 12 Jul 2016 12:30:50 +0200
- Subject: Re: Implement -Wswitch-fallthrough
- Authentication-results: sourceware.org; auth=none
- References: <20160711194340.GI13963@redhat.com> <CAFiYyc2YJSRbTVv=JEBnA+zs6spqxpki8oQOP8o_u0=vrSdC_g@mail.gmail.com>
On Tue, Jul 12, 2016 at 12:27:31PM +0200, Richard Biener wrote:
> On Mon, Jul 11, 2016 at 9:43 PM, Marek Polacek <email@example.com> wrote:
> > The switch fallthrough has been widely considered a design defect in C, a
> > misfeature or, to use Marshall Cline's definition, evil. The overwhelming
> > majority of the time you don't want to fall through to the next case, but it is
> > easy to forget to "break" at the end of the case, making this far too error
> > prone. Yet GCC (and probably other compilers, too) doesn't have the ability to
> > warn in this case. A feature request for such warning was opened back in 2002,
> > but it's mostly been untouched since. But then the [[fallthrough]] attribute was
> > approved for C++17 , and that's what has got me to do all this.
> I don't like this too much given the churn it requires in GCC itself.
> If [[fallthrough]]
> was approved for C++17 is there sth similar proposed for C? Like a keyword
I don't think there is.