Skip to content
Snippets Groups Projects
Commit 11a5b5ed authored by Ruben Asplund's avatar Ruben Asplund
Browse files

D

parent e643b6d0
No related branches found
No related tags found
No related merge requests found
......@@ -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"]
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment