Skip to content
Snippets Groups Projects
Commit 9f860c9b authored by Blinningjr's avatar Blinningjr
Browse files

B

parent 16c7a57e
Branches
No related tags found
No related merge requests found
......@@ -11,7 +11,11 @@ use panic_klee as _;
fn sum_first_elements(arr: &[u8], index: usize) -> u8 {
let mut acc = 0;
for i in 0..index {
acc += arr[i as usize];
if index < arr.len() {
acc += arr[i as usize];
} else {
break;
}
}
acc
}
......@@ -37,7 +41,22 @@ fn main() {
// Try to explain in your own words the difference and why?
// (Hint, even if we don't use the result `b`, Rust do not optimize out the call, why?)
//
// [your answer here]
// [your answer here]]
// The diffrence is that debug test all 10 possible paths and release only checks 2. This is becaus
// 9 of the paths are basicly the same. These are the path were index is 0..8, the last path is
// diffrent because then the index is out side of the array(index = 255), thus there will be an error.
//
//
// Debug:
// KLEE: done: total instructions = 4686
// KLEE: done: completed paths = 10
// KLEE: done: generated tests = 10
//
// Release:
// KLEE: done: total instructions = 32
// KLEE: done: completed paths = 2
// KLEE: done: generated tests = 2
//
//
// B) Fix the code so that you don't get an error.
// (It should still compute the sum of the n first elements
......
......@@ -85,7 +85,8 @@ fn main() {
//
// [your answer here]
// There are a lot of flags in the command which makes it a bit long to write. Maybe add a new
// command for emitting llvm-ir files or maybe combine some of the flags into one.
// command for emitting llvm-ir files or maybe add a combinedflag that combines some of the flags
// into one.
//
// C) Inner workings.
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment