D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2463 - No line number in "statement is not reachable" warning
Summary: No line number in "statement is not reachable" warning
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P3 normal
Assignee: No Owner
URL:
Keywords: diagnostic, patch
Depends on:
Blocks: 2235
  Show dependency treegraph
 
Reported: 2008-11-19 18:00 UTC by Vladimir Vlasov
Modified: 2014-03-01 00:36 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 Vladimir Vlasov 2008-11-19 18:00:18 UTC
dmd test.d -w
warning - Error: statement is not reachable

=== test.d ===
void foo()
{
	assert(0);
	return 0;
}
Comment 1 Stewart Gordon 2008-11-19 18:41:13 UTC
Please remember to assign keywords to bug reports.  To everybody reading this: Please look through issues you've reported and check for missing keywords.

This error is also an instance of issue 952.
Comment 2 Witold Baryluk 2009-11-24 16:27:27 UTC
It also hapens in more complicated situations. Out of curriosity I added -w to my project, and found few this "warning - Error: statment is not reachble" statments, and compilation failed. I have no idea where the problem is exactly, because this is big projects, with many templates.

What is interesting for some of this warning i have lines numbers like:

warning - corod.d(389): Error: statement is not reachable

but for most:

warning - Error: statement is not reachable

And i can't find good rule when I have line number and when i don't.

Small example:


$ dmd2 -w A.d 
warning - Error: statement is not reachable

=== A.d ====
class A {
	void f() {
		while (true) {}
		return 0;
	}
}
Comment 3 Witold Baryluk 2009-11-24 16:27:59 UTC
I forgot to add in my last Comment, that I'm using DMD 2.032
Comment 4 Don 2010-02-01 00:02:27 UTC
This is because statement.c, line 3515, at the end of ReturnStatement::semantic()
sets loc to zero.
//----

    if (exp && tbret->ty == Tvoid && !implicit0)
    {
	/* Replace:
	 *	return exp;
	 * with:
	 *	exp; return;
	 */
	Statement *s = new ExpStatement(loc, exp);
	exp = NULL;
	s = s->semantic(sc);
-	loc = 0;
	return new CompoundStatement(loc, s, this);
    }

    return this;
}
Comment 5 Walter Bright 2010-02-04 02:24:31 UTC
changeset 364
Comment 6 Walter Bright 2010-03-08 22:18:31 UTC
Fixed dmd 1.057 and 2.041