[Issue 1892] New: min and max work improperly for mixed-sign numbers

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 4 08:55:55 PST 2008


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

           Summary: min and max work improperly for mixed-sign numbers
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: andrei at metalanguage.com
        ReportedBy: andrei at metalanguage.com


(From a post by bearophile.)

void main() {
    int a = -10;
    uint b = 10;
    writefln( min(a, b) );
}

prints 10 as per the infamous "uint rot" that transforms everything touched by
uint an uint as well.

Not sure what the right solution is - either (a) fix CommonType to yield no
common type for int and uint, (b) fix CommonType to yield long for those two,
(c) leverage the semantics of min to yield int whenever the min of an int an
uint is taken, (d) something else?


-- 



More information about the Digitalmars-d-bugs mailing list