Bug 1892 – min and max work improperly for mixed-sign numbers

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-03-04T10:55:00Z
Last change time
2015-06-09T05:14:53Z
Assigned to
andrei
Creator
andrei

Comments

Comment #0 by andrei — 2008-03-04T10:55:54Z
(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?
Comment #1 by andrei — 2008-03-07T00:27:39Z
Fixed in 2.012.