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

Exercise B and C

parent f7a47b34
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,7 @@ fn main() { ...@@ -19,7 +19,7 @@ fn main() {
let end = core.DWT.cyccnt.read(); let end = core.DWT.cyccnt.read();
let _time = end - start; // let _time = end.wrapping_sub(start);
} }
// A) Running KLEE on embedded code: // A) Running KLEE on embedded code:
...@@ -166,7 +166,9 @@ fn main() { ...@@ -166,7 +166,9 @@ fn main() {
// //
// What do you get, and why? // 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? // As you should have seen, this was not particularly informative, right?
// //
...@@ -197,15 +199,19 @@ fn main() { ...@@ -197,15 +199,19 @@ fn main() {
// //
// Value of `start`. // Value of `start`.
// //
// [your answer here] // [start = 0]
// //
// Value of `end` // Value of `end`
// //
// [your answer here] // [end = 0]
// //
// Why does these values cause an error debug/dev build but not in a release build? // 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! // C) Fix the problem!
// //
...@@ -217,7 +223,8 @@ fn main() { ...@@ -217,7 +223,8 @@ fn main() {
// There are numerous ways to solve the problem. // There are numerous ways to solve the problem.
// Argue for your solution in your own words. // 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. // 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