You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code linked below can overflow when any of the products is above i32::MAX, potentially leading to a much larger memory allocation than intended (example). There are a few other instances in other calls to vec_uninit
#[allow(arithmetic_overflow)]fnmain(){let m:i32 = 2_000;let n:i32 = 1_080_000;println!("{}", m * n);println!("{}", (m * n)asusize);println!("{}", m asusize * n asusize);}
Run in debug mode, it panics.
thread 'main' panicked at 'attempt to multiply with overflow', src/main.rs:5:20
Run in release mode, silent arithmetic integer overflow.
-2134967296
18446744071574584320
2160000000
All occurrences of (x * y) as usize where x and y are i32 ought to be x as usize * y as usize. When x and y are i32 and known to be positive, x as usize * y as usize cannot overflow.
The code linked below can overflow when any of the products is above
i32::MAX
, potentially leading to a much larger memory allocation than intended (example). There are a few other instances in other calls tovec_uninit
https://github.com/rust-ndarray/ndarray-linalg/blob/master/lax/src/svddc.rs#L44-L49
The text was updated successfully, but these errors were encountered: