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

            Bug ID: 90631
           Summary: this statement may fall through
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jg at jguk dot org
  Target Milestone: ---

I appreciate the option -Wimplicit-fallthrough gives a clue. I think it could
be clearer.

Currently g++ says "this statement may fall through"
Actually it definitely does fall through in this simple example below. So
perhaps the message could be "this statement falls through" if that can be
determined?  All statements without a return, break, continue perhaps?


#1 with x86-64 gcc (trunk)
<source>: In function 'int main()':
<source>:8:15: error: this statement may fall through
[-Werror=implicit-fallthrough=]
    8 |             a = 2;
      |             ~~^~~
<source>:10:9: note: here
   10 |         default:
      |         ^~~~~~~
cc1plus: all warnings being treated as errors
Compiler returned: 1



int main()
{
   int a = 1;
   switch(a)
   {
        case 1:
        {
            a = 2;
        }
        default:
        {
            a = 3;
        }
   }

   return a;
}

Reply via email to