On Thursday, 17 March 2016 at 09:59:41 UTC, Dominikus Dittes Scherkl wrote:
Or you can use an improved opCmp implementation in the compiler, that only add additional runtime cost, if someone is stupid enough to compare signed with unsigned values - but yield the correct result:

I should also point out that, while it would have been eminently sensible for D to just implement signed/unsigned comparison correctly in the first place - fixing this now would be a silent breaking change.

I'm fairly confident that it would cause real-world problems, as I myself can recall trying to write code that intentionally leveraged the current bizarre behavior to eke out a little more speed, in the past.

Such code could be trivially fixed with the addition of a `cast(uint)` or the like in the right place, BUT only if someone actually remembered that it needed to be fixed: neither the compiler, nor dfix could automatically detect the rare code that deliberately depends on the current behavior.

So, I think Walter and Andrei made the right call by saying to make it a warning. Maybe later though, after a *long* deprecation period, we could fix it to check for negative values like it should.

Reply via email to