[rust-dev] Integer overflow, round -2147483648

Florian Zeitz florob at babelmonkeys.de
Wed Jun 25 15:21:54 PDT 2014

On 26.06.2014 00:04, Vadim Chugunov wrote:
> I wasn't thinking of subtyping u32w to u32.  I actually don't think that
> u32 should be convertible to u32w (or vice-versa) without an explicit
> cast.   For array slices, it would have to be a transmute-like function,
> e.g. fn as_wrapping<'a>(s:&'a [u32])->&'a [u32w] { unsafe { transmute(s) } }
FWIW, as I understand it RFC PR #91
<https://github.com/rust-lang/rfcs/pull/91> would nicely deal with such
cases, by making `u32` and `u32w` coercible. I don't think there is any
reason for `u32w` not to be just a newtype of `u32` with appropriate
arithmetic trait impls.

More information about the Rust-dev mailing list