This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: GCC 7.1 Fallthrough Warning Question
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Josh <snapcore at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Tue, 26 Sep 2017 22:25:44 +0100
- Subject: Re: GCC 7.1 Fallthrough Warning Question
- Authentication-results: sourceware.org; auth=none
- References: <CAL4cRdtD7wn31BDD6w9e6TsvJnXnk2juWO0fL+MW2jj1E9nNJQ@mail.gmail.com>
On 26 September 2017 at 20:54, Josh wrote:
> For gcc 7.1.1, I noticed the following will give a warning ("warning:
> this statement may fall through") if you have -Wall on:
>
> switch (Z) {
> case X: {
> break;
> }
> // fallsthrough
> default: {
> //..some code
> }
> }
I don't get any warning for a simple example based on this snippet.
Could you show a complete example that we can actually compile to
reproduce the warning you see?
> but removing the braces around the default block fixes it:
>
> switch (Z) {
> case X: {
> break;
> }
> // fallsthrough
> default:
> //..some code
> }
>
> Is this intended or a possible bug?
>
> -Josh