pu$�le

strtr strtr at sp.am
Sun Jul 18 17:36:58 PDT 2010


== Quote from Jonathan M Davis (jmdavisprog at gmail.com)'s article
> On Sunday 18 July 2010 00:46:36 Jonathan M Davis wrote:
> > I'll file a bug report
> >
> > - Jonathan M Davis
> Wait. That's not the problem. Or at least, that's not the problem that needs to
> be reported. The problem is that we're not compiling with -w. If you compile
> with -w, then statements such as
> scope(failure) continue;
> won't compile due to being unreachable statements. But if you compile with -w,
> then the compiler flags it as an error, and the program fails to compile. So, I
> filed a bug report on the fact that such warnins aren't reported without -w
> (though they would still compile since they're warnings rather than errors):
> http://d.puremagic.com/issues/show_bug.cgi?id=4482
> Regardless, what you're trying to do is clearly an error, and compiling with -w
> will show that.
> - Jonathan M Davis

I don't agree with this bug report because of two reasons.
1. Warnings are supposed to be warnings, not errors. If you want to see those
warnings you'll use -w.
What you probably want is for the dmd to have a -!w flag instead (warnings by
default, disable with flag)
2. In this particular example, the problem is not that the warning isn't shown
without -w, but that the warning is incorrect and scope(failure) shouldn't be able
to catch the exception.

Here is a smaller example of the same problem[D1]:
----
void main()
{
	for(int i=0;i<10;i++)
	{
		scope(failure){
			writefln("continue");
			continue;
		}
		//scope(failure) writefln("fail");
		writefln(i);
		throw new Exception(format(i));
	}
}
----

Enable warnings and you'll get the same unreachable warning, but which statement
is unreachable as when you compile this without -w it happily prints all ten i's
and continues.


More information about the Digitalmars-d-learn mailing list