[Issue 6377] std.conv.to should check range when changing signedness

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 24 16:06:41 PDT 2011


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


Jonathan M Davis <jmdavisProg at gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg at gmx.com
           Platform|Other                       |All
         OS/Version|Windows                     |All
           Severity|normal                      |enhancement


--- Comment #1 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-07-24 16:06:40 PDT ---
That's debatable. There _are_ cases where you wouldn't want a negative value to
be converted to an unsigned integral value, but there are also cases where you
_would_ want it to happen. For better or worse, unsigned integral values
implicitly convert to signed integral values of the same size. It ends up using
the most basic version of std.conv.to

T toImpl(T, S)(S value)
    if (isImplicitlyConvertible!(S, T))
{
    return value;
}

This isn't a bug. It _might_ be a change that we want to make, but it's not a
bug. This is the expected behavior. You wouldn't get any more of an error if
you just assigned to a uint from an int directly.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list