diff --git a/cargo_klee_examples/examples/array.rs b/cargo_klee_examples/examples/array.rs index afb61709e5380f2f8b02989738d934b9e78c5bb4..322e58975e91392ae35eee1276c2fbd1eebe3b3e 100644 --- a/cargo_klee_examples/examples/array.rs +++ b/cargo_klee_examples/examples/array.rs @@ -8,11 +8,11 @@ use klee_sys::klee_make_symbolic; use panic_klee as _; -fn sum_first_elements(arr: &[u8], index: usize) -> u8 { - let mut acc = 0; +fn sum_first_elements(arr: &[u8], index: usize) -> u16 { + let mut acc: u16 = 0; let index = core::cmp::min(arr.len(), index); for i in 0..index { - acc += arr[i as usize]; + acc += arr[i as usize] as u16; } acc } @@ -65,12 +65,12 @@ fn main() { // // Explain what caused the error. // -// [your answer here] +// [It seems to be a overflow problem in the varaible acc.] // // E) Make a sensible fix to the code. // Motivate your choice. // -// [your answer here] +// [I changed the acc variable to a u16. It will allow bigger values without overflowing.] // // [Git commit "D"] //