size_t index=-1;

tsbockman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Mar 19 04:03:43 PDT 2016


On Saturday, 19 March 2016 at 10:01:41 UTC, Basile B. wrote:
> Yes and that's the opposite that should happend: when signed 
> and unsigned are mixed in a comparison, the unsigned value 
> should be implictly cast to a wider signed value. And then it 
> works!

That would be reasonable. Whether it's actually faster than just 
inserting an extra check for `signed_value < 0` in mixed 
comparisons is likely platform dependent, though.

Honestly though - even just changing the rules to implicitly 
convert both operands to a signed type of the same size, instead 
of an unsigned type of the same size, would be a huge 
improvement. Small negative values are way more common than huge 
(greater than signed_type.max) positive ones in almost all code. 
(This change will never happen, of course, as it would be far too 
subtle of a breaking change for existing code.)

Regardless, the first step is to implement the pre-approved 
solution to DMD 259: deprecate the current busted behavior.


More information about the Digitalmars-d-learn mailing list