D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8052 - Spurious warning when exiting out of a labeled Do-While
Summary: Spurious warning when exiting out of a labeled Do-While
Status: REOPENED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 minor
Assignee: No Owner
URL:
Keywords: diagnostic, rejects-valid
Depends on:
Blocks:
 
Reported: 2012-05-06 04:06 UTC by kekeniro2
Modified: 2024-12-13 17:59 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kekeniro2 2012-05-06 04:06:47 UTC
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 callumenator 2014-07-28 05:46:55 UTC
No warning given with dmd 2.065, or earlier at 2.061.
Comment 2 jiki 2014-07-28 06:03:11 UTC
No.
'-w' option is required to reproduce, I've missed it.

Anyway, I change the Severity to minor.
Comment 3 Dragos Carp 2014-07-30 14:36:03 UTC
The same bug without label (see bug 13201):

------------------------------

void foo()
{
}

void main()
{
    while (true)
    {
        do
        {
            foo;
            break;
        } while (true);
        break;
    }
}
Comment 4 jiki 2016-02-10 01:50:15 UTC
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.
Comment 5 Steven Schveighoffer 2023-11-14 17:32:15 UTC
We have removed the unreachable statement warning

https://github.com/dlang/dmd/pull/15568

I think this should be closed.
Comment 6 dlangBugzillaToGithub 2024-12-13 17:59:51 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

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

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