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

Exercise B and C

parent 18b4b61f
No related branches found
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ fn main() {
let end = core.DWT.cyccnt.read();
let _time = end - start;
// let _time = end.wrapping_sub(start);
}
// A) Running KLEE on embedded code:
......@@ -166,7 +166,9 @@ fn main() {
//
// What do you get, and why?
//
// [There are no value of start or end because both are optimized out.]
// [There are no value of start or end because both are optimized out.
// The variables are used for substraction, the difference value is is thrown away.
// Then start and end is useless, therefore they are optimized out.]
//
// As you should have seen, this was not particularly informative, right?
//
......@@ -197,15 +199,19 @@ fn main() {
//
// Value of `start`.
//
// [your answer here]
// [start = 0]
//
// Value of `end`
//
// [your answer here]
// [end = 0]
//
// Why does these values cause an error debug/dev build but not in a release build?
//
// [your answer here]
// [This line is causing the problem: let _time = end - start;
// When taking substraction of values two values there is a high risk that it will overflow,
// therefore the error occurs in debug/dev build.
// In release build the substractions occurs and no overflow is found then errors will not occurs.
// It seems like the release build is not detecting potential problems, only problems that occurs.]
//
// C) Fix the problem!
//
......@@ -217,7 +223,8 @@ fn main() {
// There are numerous ways to solve the problem.
// Argue for your solution in your own words.
//
// [your answer here]
// [The substraction can overflow, to remove the error and make sure the substraction is almost always correct,
// we need to use wrapper_sub.]
//
// D) Learning outcomes and major takeaways.
//
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment