From 8bb1d3e283ec5c2569a8f910452b1fb60f8e4035 Mon Sep 17 00:00:00 2001
From: rubenasplund <ruben.asplund@hotmail.com>
Date: Wed, 16 Dec 2020 16:28:26 +0100
Subject: [PATCH] D

---
 cargo_klee_examples/examples/array.rs | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/cargo_klee_examples/examples/array.rs b/cargo_klee_examples/examples/array.rs
index afb6170..322e589 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"]
 //
-- 
GitLab