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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Edvin Åkerfeldt
klee_tutorial
Commits
564c95bd
Commit
564c95bd
authored
4 years ago
by
Edvin Åkerfeldt
Browse files
Options
Downloads
Patches
Plain Diff
cargo_klee_examples/array.rs, D
parent
bddb67d2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
cargo_klee_examples/examples/array.rs
+10
-3
10 additions, 3 deletions
cargo_klee_examples/examples/array.rs
with
10 additions
and
3 deletions
cargo_klee_examples/examples/array.rs
+
10
−
3
View file @
564c95bd
...
@@ -8,10 +8,10 @@
...
@@ -8,10 +8,10 @@
use
klee_sys
::
klee_make_symbolic
;
use
klee_sys
::
klee_make_symbolic
;
use
panic_klee
as
_
;
use
panic_klee
as
_
;
fn
sum_first_elements
(
arr
:
&
[
u8
],
index
:
usize
)
->
u
8
{
fn
sum_first_elements
(
arr
:
&
[
u8
],
index
:
usize
)
->
u
16
{
let
mut
acc
=
0
;
let
mut
acc
:
u16
=
0
;
for
i
in
0
..
arr
.len
()
{
for
i
in
0
..
arr
.len
()
{
acc
+=
arr
[
i
as
usize
];
acc
+=
arr
[
i
as
usize
]
as
u16
;
}
}
acc
acc
}
}
...
@@ -84,11 +84,18 @@ Running the test case in gdb will show yhou this in the asm code (shown code is
...
@@ -84,11 +84,18 @@ Running the test case in gdb will show yhou this in the asm code (shown code is
// Explain what caused the error.
// Explain what caused the error.
//
//
// [your answer here]
// [your answer here]
/*
The value of acc overflowed.
This was caused by klee inputing max values of u8 in the array slots which when added together greatly exedes the max of u8.
*/
//
//
// E) Make a sensible fix to the code.
// E) Make a sensible fix to the code.
// Motivate your choice.
// Motivate your choice.
//
//
// [your answer here]
// [your answer here]
/*
I changed the type of the return variable to an u16, which will fit the added values.
*/
//
//
// [Git commit "D"]
// [Git commit "D"]
//
//
...
...
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