Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
klee_tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Niklas Lundberg
klee_tutorial
Commits
9f860c9b
Commit
9f860c9b
authored
4 years ago
by
Blinningjr
Browse files
Options
Downloads
Patches
Plain Diff
B
parent
16c7a57e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cargo_klee_examples/examples/array.rs
+21
-2
21 additions, 2 deletions
cargo_klee_examples/examples/array.rs
cargo_klee_examples/examples/get_sign.rs
+2
-1
2 additions, 1 deletion
cargo_klee_examples/examples/get_sign.rs
with
23 additions
and
3 deletions
cargo_klee_examples/examples/array.rs
+
21
−
2
View file @
9f860c9b
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
cargo_klee_examples/examples/get_sign.rs
+
2
−
1
View file @
9f860c9b
...
...
@@ -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.
//
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment