Bug? 0 is less than -10

Ozan via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 9 11:55:09 PDT 2015


On Thursday, 8 October 2015 at 09:01:32 UTC, Dominikus Dittes 
Scherkl wrote:
> On Wednesday, 7 October 2015 at 16:25:02 UTC, Marc Schütz wrote:
>> Lionello Lunesu posted a PR that should fix this:
>> https://github.com/D-Programming-Language/dmd/pull/1913
>> See also the discussion in the linked bug report.
>>
>> Unfortunately it seems it's been forgotten since then...
>
> Meanwhile I have even improved my solution posted to fix bug 
> #259 to use less casts:
>
> int opCmp(T, U)(const(T) a, const(U) b) pure @safe @nogc nothrow
>    if(isIntegral!T && isIntegral!U && !is(Unqual!T == Unqual!U))
> {
>    static if(isSigned!T && isUnsigned!U && T.sizeof <= U.sizeof)
...
>
> And on comparison with number literals everything will be 
> optimized away, so no execution timer overhead at all!

I like your solution!  +1


More information about the Digitalmars-d-learn mailing list