https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77817

Anton Maklakov <antmak.pub at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |antmak.pub at gmail dot com

--- Comment #16 from Anton Maklakov <antmak.pub at gmail dot com> ---
Hi,

I have the same problem:


int main() {
    int s = 1;

    switch (s) {
        case 2:
            s = 2;
#if B
            break;
#else
            s = 4;
            /* falls through */
#endif
        case 3:
            s = 3;
    }
} 

It appears

prog.c: In function 'main':
prog.c:11:15: warning: this statement may fall through
[-Wimplicit-fallthrough=]
             s = 4;
             ~~^~~
prog.c:14:9: note: here
         case 3:
         ^~~~

At the moment I use a workaround:

#if (__GNUC__ >= 7)
#    define FALLTHROUGH __attribute__ ((fallthrough));
#else
#    define FALLTHROUGH
#endif

int main() {
    int s = 1;

    switch (s) {
        case 2:
            s = 2;
#if B
            break;
#else            
            s = 4;
            FALLTHROUGH
#endif
        case 3:   
            s = 3;
    }
}

This code is based on the real code from libexpat

Reply via email to