Jump to page: 1 2
Thread overview
[Issue 13858] Wrong warning about unreachable code with break/goto case
Dec 12, 2014
Andrej Mitrovic
Dec 12, 2014
Andrej Mitrovic
Dec 12, 2014
Andrej Mitrovic
Dec 15, 2014
Dicebot
Dec 15, 2014
Dicebot
Jan 24, 2015
yebblies
Jan 24, 2015
Dicebot
Jan 25, 2015
Walter Bright
Jan 26, 2015
Dicebot
December 12, 2014
https://issues.dlang.org/show_bug.cgi?id=13858

Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86_64                      |All
            Version|D2                          |D1 & D2
                 OS|Linux                       |All

--
December 12, 2014
https://issues.dlang.org/show_bug.cgi?id=13858

Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|enhancement                 |normal

--
December 12, 2014
https://issues.dlang.org/show_bug.cgi?id=13858

--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> ---
Also, the same thing happens with 'goto', although I'm not sure whether there's a semantic difference between the two (I assume so).

--
December 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13858

Dicebot <public@dicebot.lv> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor

--
December 15, 2014
https://issues.dlang.org/show_bug.cgi?id=13858

Dicebot <public@dicebot.lv> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry
                 CC|                            |public@dicebot.lv

--- Comment #2 from Dicebot <public@dicebot.lv> ---
Affects both D1 and D2

--
January 24, 2015
https://issues.dlang.org/show_bug.cgi?id=13858

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com

--- Comment #3 from yebblies <yebblies@gmail.com> ---
(In reply to Andrej Mitrovic from comment #1)
> Also, the same thing happens with 'goto', although I'm not sure whether there's a semantic difference between the two (I assume so).

If by that you mean replacing the 'break LSwitch' with 'goto LSwitch' then the warning is correct, because that would be an infinite loop.

The problem here is that LabelStatement::blockExit just returns the blockExit of the labeled statement, and isn't really designed for handling a label containing a goto to itself.

BreakStatement::blockExit produces BEgoto when used with a label, but this is overly vague, as labeled breaking from a switch should produce BEfallthru.

I tried changing SwitchStatement::blockExit to treat an internal BEgoto as BEfallthrough, like ForStatement does, but it seems to also use BEgoto to indicate internal 'goto case's and that change leads to false positive "no return exp; or assert(0)" errors.

I'm not sure it's possible to fix this without properly building and walking a CFG, maybe somebody else knows for sure.

--
January 24, 2015
https://issues.dlang.org/show_bug.cgi?id=13858

--- Comment #4 from Dicebot <public@dicebot.lv> ---
I'll mark it as "hard to fix, better use workaround" then :)

--
January 25, 2015
https://issues.dlang.org/show_bug.cgi?id=13858

--- Comment #5 from github-bugzilla@puremagic.com ---
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/7ba6bac8d7f3433610b8a9cc9e0dfa8d887628c0
fix
Issue 13858 - Wrong warning about unreachable code with break/goto case

--
January 25, 2015
https://issues.dlang.org/show_bug.cgi?id=13858

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> ---
D2 fix:

https://github.com/D-Programming-Language/dmd/pull/4337

--
January 25, 2015
https://issues.dlang.org/show_bug.cgi?id=13858

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
« First   ‹ Prev
1 2