Thread overview |
---|
October 28, 2007 [Issue 1620] New: std.conv.to fails for integer unsigned->signed conversion | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1620 Summary: std.conv.to fails for integer unsigned->signed conversion Product: D Version: 2.006 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: bugzilla@digitalmars.com ReportedBy: i.kasiuk@gmx.de A conversion like to!(int)(123u) fails, producing the following error at runtime: Error: Error: overflow Conversion underflow Here is the code from conv.d which does the check: static const sSmallest = isFloatingPoint!(S) ? -S.max : S.min, tSmallest = isFloatingPoint!(T) ? -T.max : T.min; static if (sSmallest < tSmallest) { // possible underflow if (value < tSmallest) conv_overflow("Conversion underflow"); } ... This apparently doesn't work as intended because of the implicit conversions happening when the values are compared. Actually, why does the compiler silently do an implicit type conversion here? I think this is a bit unfortunate. -- |
March 01, 2008 [Issue 1620] std.conv.to fails for integer unsigned->signed conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1620 ------- Comment #1 from i.kasiuk@gmx.de 2008-03-01 12:31 ------- The bug is still present in version 2.011. -- |
March 01, 2008 [Issue 1620] std.conv.to fails for integer unsigned->signed conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1620 andrei@metalanguage.com changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|bugzilla@digitalmars.com |andrei@metalanguage.com ------- Comment #2 from andrei@metalanguage.com 2008-03-01 17:40 ------- I actually fixed this in my tree. The fix will be part of the next release. Thanks! -- |
March 07, 2008 [Issue 1620] std.conv.to fails for integer unsigned->signed conversion | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1620 andrei@metalanguage.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #3 from andrei@metalanguage.com 2008-03-07 00:38 ------- Fixed in 2.012. -- |
Copyright © 1999-2021 by the D Language Foundation