Closed warren2k closed 1 year ago
On rust 1.72.0
(stable), thread 'main' panicked at 'attempt to add with overflow', benches\bench1.rs:584:19
fn kmerge_tenway(c: &mut Criterion) {
let mut data = vec![0; 10240];
let mut state = 1729u16;
fn rng(state: &mut u16) -> u16 {
let new = state.wrapping_mul(31421) + 6927; // <----
*state = new;
new
}
for elt in &mut data {
*elt = rng(&mut state);
}
// ...
That seems to be quite old code. Investigating further...
Looking further into this, it seems there's no attempt to run this in CI. Maybe this is not an issue.
It was added in #101 (feb. 2016... ...): https://github.com/rust-itertools/itertools/pull/101/files#diff-5e88c455e47e41d2006104fe8795309466144a7dc0b25f98632e7b85ec90b866R674
I ran cargo test --bench bench1
on old commits (like a year ago and more) and got the same error.
That's definitely weird, good catch anyway.
Running the associated bench cargo bench "kmerge tenway"
is fine though. I don't understand.
...Oh... bench uses release
profile so it's silently ignored: wrapping_add
would fix this I guess.
EDIT: It does.
At least, it fails with toolchain version 1.72.1