This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: -Wimplicit-fallthrough broken?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Georg-Johann Lay <avr at gjlay dot de>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Fri, 21 Jul 2017 07:35:29 -0400
- Subject: Re: -Wimplicit-fallthrough broken?
- Authentication-results: sourceware.org; auth=none
- References: <596FBE8C.4030506@gjlay.de>
- Reply-to: noloader at gmail dot com
On Wed, Jul 19, 2017 at 4:18 PM, Georg-Johann Lay <avr@gjlay.de> wrote:
> Hi, with the following small small test I am getting these warnings:
>
> void test1 (unsigned char c)
> {
> switch (c)
> {
> case 1: c++; // fallthrough
> case 2: c--; // FALLTHRU
> case 3: c++; // FALLTHROUGH
> case 4: z = c; break;
> }
> }
>
> void test2 (unsigned char c)
> {
> switch (c)
> {
> case 1: c++;
> /* fallthrough */
> case 2: c--;
> /* FALLTHRU */
> case 3: c++;
> /* FALLTHROUGH */
> case 4: z = c; break;
> }
> }
> ...
>
> How do I have to formulate these comments? It's under mingw32, may that be
> a problem?
Clang handles the case statements in the first switch and the second switch.
GCC only handles the the second switch statement.
GCC also does not handle this form, which Clang will:
switch (c)
{
// All fallthrough
case 1: c++;
case 2: c--;
...
}
Or maybe I should say, as of GCC 7.1. I hope they will be fixing it soon.
Jeff