Thread overview
[Issue 15731] Analysis error on explicit case fall-through
Feb 27, 2016
Johan Engelen
Oct 28, 2018
coolfool4@gmx.com
Oct 28, 2018
coolfool4@gmx.com
Oct 28, 2018
coolfool4@gmx.com
Nov 03, 2022
RazvanN
Nov 03, 2022
Dennis
Dec 17, 2022
Iain Buclaw
February 27, 2016
https://issues.dlang.org/show_bug.cgi?id=15731

--- Comment #1 from Johan Engelen <jbc.engelen@gmail.com> ---
DMD version = 2.070.0

--
October 28, 2018
https://issues.dlang.org/show_bug.cgi?id=15731

coolfool4@gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |coolfool4@gmx.com

--- Comment #2 from coolfool4@gmx.com ---
I can't get errors nor warnings for fallthroughs except with final switches on enums (-w or -wi don't help).

Compiler versions:
- DMD64 D Compiler v2.082.0
- nightly at https://run.dlang.io/


import std.stdio;

void main() {
    int x = 0;
    switch (x) {
        case 0:
        case 1:
            writeln("woot");
            return;
        default:
    }
}

--
October 28, 2018
https://issues.dlang.org/show_bug.cgi?id=15731

--- Comment #3 from coolfool4@gmx.com ---
Actually I don't get fallthrough warnings for *any* switches.

--
October 28, 2018
https://issues.dlang.org/show_bug.cgi?id=15731

--- Comment #4 from coolfool4@gmx.com ---
So it seems to accept *empty* cases to fall through. I guess this is intended, then?

--
November 03, 2022
https://issues.dlang.org/show_bug.cgi?id=15731

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |WORKSFORME

--- Comment #5 from RazvanN <razvan.nitu1305@gmail.com> ---
When compiling the initial example I get:

test.d(18): Error: switch case fallthrough - use 'goto case;' if intended


This seems to have been fixed

--
November 03, 2022
https://issues.dlang.org/show_bug.cgi?id=15731

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |dkorpel@live.nl
         Resolution|WORKSFORME                  |---

--- Comment #6 from Dennis <dkorpel@live.nl> ---
(In reply to RazvanN from comment #5)
> When compiling the initial example I get:
> 
> test.d(18): Error: switch case fallthrough - use 'goto case;' if intended
> 
> 
> This seems to have been fixed

The problem is that with -version=bad, it incorrectly raises an error about missing a return statement or assert(0). That's still the case.

Here's a reduced example:
```
// accepts valid
int a()
{
    while (1)
    {
        switch (0)
        {
            case 0: // < implicit fallthrough
            default: continue;
        }
    }
}

// rejects valid
int b()
{
    while (1)
    {
        switch (0)
        {
            case 0: goto default; // < explicit fallthrough
            default: continue;
        }
    }
}
```

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=15731

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=15731

--- Comment #7 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19101

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--