Building the following code, I get an incorrect warning.
int test()
{
loop:
do {
break loop;
} while(false);
return 0; // isn't unreachable.
}
-----------------------------------
Warning: statement is not reachable
D1 does not warn.
Comment #1 by callumenator — 2014-07-28T05:46:55Z
No warning given with dmd 2.065, or earlier at 2.061.
Comment #2 by jiki — 2014-07-28T06:03:11Z
No.
'-w' option is required to reproduce, I've missed it.
Anyway, I change the Severity to minor.
Comment #3 by dragoscarp — 2014-07-30T14:36:03Z
The same bug without label (see bug 13201):
------------------------------
void foo()
{
}
void main()
{
while (true)
{
do
{
foo;
break;
} while (true);
break;
}
}
Comment #4 by jiki — 2016-02-10T01:50:15Z
I hit this again.
The bug seems a careless bit operation.
Location:
statement.d
Statement.blockExit()
BlockExit.visit(DoStatement)
Code:
if (result == BEbreak) // '==' should be '&'
...
if (result & BEcontinue)
...
I wanted to make a PR, but I don't see how the other flags work.