This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -Wimplicit-fallthrough broken?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]