[Issue 1892] New: min and max work improperly for mixed-sign numbers
Bill Baxter
dnewsgroup at billbaxter.com
Tue Mar 4 15:45:07 PST 2008
d-bugmail at puremagic.com wrote:
> 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?
>
>
So you *do* still read the newsgroups. ;-)
--bb
More information about the Digitalmars-d-bugs
mailing list