[Bug c/77955] -Wimplicit-fallthrough=1 issue

2016-10-12 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77955

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #6 from Marek Polacek  ---
Ah, right.  Ok.

*** This bug has been marked as a duplicate of bug 77817 ***

[Bug c/77955] -Wimplicit-fallthrough=1 issue

2016-10-12 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77955

--- Comment #5 from Markus Trippelsdorf  ---
(In reply to Marek Polacek from comment #4)
> It'll be hard to "fix" the first testcase:
> .

Thanks.

The testcase from comment 3 is a dup of pr77886 and fixed by 
the patch that Jakub posted there.

So if there is already an existing bug for the first testcase,
feel free to close this bug.

[Bug c/77955] -Wimplicit-fallthrough=1 issue

2016-10-12 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77955

--- Comment #4 from Marek Polacek  ---
It'll be hard to "fix" the first testcase:
.

[Bug c/77955] -Wimplicit-fallthrough=1 issue

2016-10-12 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77955

--- Comment #3 from Markus Trippelsdorf  ---
Another issue:

markus@x4 /tmp % cat fall.c
void bar(int);

template  void foo(int i, bool bo) {
  switch (i) {
  case 1:
if (!bo)
  break;
  // Fall through.
  case 2:
bar(2);
  default:
break;
  }
}

template void foo(int, bool);
template void foo(int, bool);

markus@x4 /tmp % g++ -Wimplicit-fallthrough=1 -c fall.c
fall.c: In function ‘void foo(int, bool) [with T = int]’:
fall.c:6:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
 if (!bo)
 ^~
fall.c:9:3: note: here
   case 2:
   ^~~~
fall.c: In function ‘void foo(int, bool) [with T = void*]’:
fall.c:6:5: warning: this statement may fall through [-Wimplicit-fallthrough=]
 if (!bo)
 ^~
fall.c:9:3: note: here
   case 2:
   ^~~~

[Bug c/77955] -Wimplicit-fallthrough=1 issue

2016-10-12 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77955

--- Comment #2 from Markus Trippelsdorf  ---
(In reply to Marek Polacek from comment #1)
> (In reply to Markus Trippelsdorf from comment #0)
> > As you can see gcc issues a bogus warning and doesn't warn for the case 2
> > fallthrough.
> 
> It falls through to default: break; so it should warn for that case.

Yes, that is what I meant to say.

[Bug c/77955] -Wimplicit-fallthrough=1 issue

2016-10-12 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77955

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek  ---
(In reply to Markus Trippelsdorf from comment #0)
> As you can see gcc issues a bogus warning and doesn't warn for the case 2
> fallthrough.

It falls through to default: break; so it should warn for that case.