D-Programming-Language/dmd — pull request #1913 by lionello (2013-04-19 16:24:01+00:00)
Title: Bug 259 Comparing signed to unsigned does not generate an error

http://d.puremagic.com/issues/show_bug.cgi?id=259

Consider a comparison a < b, a <= b, a > b, or a >= b, in which a and b are
integral types of different signedness. Without loss of generality, let's
consider a is signed and b is unsigned and the comparison is a < b. Then we
have the following cases:

1. If a.sizeof > b.sizeof, then a < b is lowered into a < cast(typeof(a)) b.
Then signed comparison proceeds normally. This is a classic value-based
conversion dating from the C days, and we do it in D as well.

2. Otherwise, if a is determined through Value Range Propagation to be greater
than or equal to zero, then a < b is lowered into cast(U) a < b, where U is the
unsigned variant of typeof(a). Then unsigned comparison proceeds normally.

3. Otherwise, the comparison is in error.

Using deprecation() since warnings and errors during template instantiations are suppressed and the final "errors instantiating template" doesn't say why ( http://d.puremagic.com/issues/show_bug.cgi?id=9960 )