diff --git a/cargo_klee_examples/examples/array.rs b/cargo_klee_examples/examples/array.rs index 9ec5e1001018328b5faced47a765caf80b610028..f1fa1b7da759444246c3703f50e1b3d5096c7f10 100644 --- a/cargo_klee_examples/examples/array.rs +++ b/cargo_klee_examples/examples/array.rs @@ -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 diff --git a/cargo_klee_examples/examples/get_sign.rs b/cargo_klee_examples/examples/get_sign.rs index 56fe57c99b15b0981ddb67ebe37fac0e67b7906a..c955577fa15f79fcc58f66628d264524ac78512b 100644 --- a/cargo_klee_examples/examples/get_sign.rs +++ b/cargo_klee_examples/examples/get_sign.rs @@ -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. //