-Wimplicit-fallthrough broken?

Georg-Johann Lay avr@gjlay.de
Wed Jul 19 20:17:00 GMT 2017


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;
     }
}



simple.c: In function 'test1':
simple.c:7:18: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
          case 1: c++; // fallthrough
                  ~^~
simple.c:8:9: note: here
          case 2: c--; // FALLTHRU
          ^~~~
simple.c:8:18: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
          case 2: c--; // FALLTHRU
                  ~^~
simple.c:9:9: note: here
          case 3: c++; // FALLTHROUGH
          ^~~~
simple.c:9:18: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
          case 3: c++; // FALLTHROUGH
                  ~^~
simple.c:10:9: note: here
          case 4: z = c; break;
          ^~~~
simple.c: In function 'test2':
simple.c:18:18: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
          case 1: c++;
                  ~^~
simple.c:20:9: note: here
          case 2: c--;
          ^~~~
simple.c:20:18: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
          case 2: c--;
                  ~^~
simple.c:22:9: note: here
          case 3: c++;
          ^~~~
simple.c:22:18: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
          case 3: c++;
                  ~^~
simple.c:24:9: note: here
          case 4: z = c; break;
          ^~~~


How do I have to formulate these comments?  It's under mingw32, may that 
be a problem?

Johann



More information about the Gcc-help mailing list