File tree Expand file tree Collapse file tree 8 files changed +137
-0
lines changed Expand file tree Collapse file tree 8 files changed +137
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ unsigned fib (unsigned x )
4
+ {
5
+ switch (x )
6
+ {
7
+ case 0 :
8
+ return 0 ;
9
+ break ;
10
+ case 1 :
11
+ return 1 ;
12
+ break ;
13
+ default :
14
+ return fib (x - 1 ) + fib (x - 2 );
15
+ break ;
16
+ }
17
+ }
18
+
19
+ int main (int argc , char * * argv )
20
+ {
21
+ unsigned v = fib (7 );
22
+ assert (v == 13 ); // Requires context sensitivity to handle with constants
23
+
24
+ unsigned w = fib (9 );
25
+ assert (w == 24 ); // Requires location, not just function tracking
26
+
27
+ return 0 ;
28
+ }
Original file line number Diff line number Diff line change
1
+ FUTURE
2
+ main.c
3
+ --verify --recursive-interprocedural --call-stack 10 --constants --one-domain-per-history
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^\[main.assertion.1\] .* assertion v == 13: SUCCESS$
7
+ ^\[main.assertion.2\] .* assertion w == 24: SUCCESS$
8
+ --
9
+ ^warning: ignoring
10
+ --
11
+ This should be possible just tracking constants and calling stacks.
12
+ At the moment the --constants domain can't do it due to the way it proactively merges to handle recursion.
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ int negate (int x )
4
+ {
5
+ return - x ;
6
+ }
7
+
8
+ int main (int argc , char * * argv )
9
+ {
10
+ int x = 23 ;
11
+ int nx = negate (x );
12
+ int nnx = negate (nx );
13
+
14
+ assert (x == nnx );
15
+
16
+ return 0 ;
17
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --verify --recursive-interprocedural --call-stack 0 --constants --one-domain-per-history
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^\[main.assertion.1\] .* assertion x == nnx: SUCCESS$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ A simple test of call stacks and context sensitivity. Merging calling context with contexts will give a failure.
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ int step (int x )
4
+ {
5
+ if (x <= 0 )
6
+ {
7
+ return 0 ;
8
+ }
9
+ else
10
+ {
11
+ return x + step (x - 1 );
12
+ }
13
+ }
14
+
15
+ int main (int argc , char * * argv )
16
+ {
17
+ int x = 5 ;
18
+ int res = step (x );
19
+
20
+ assert (res == 15 );
21
+
22
+ return 0 ;
23
+ }
Original file line number Diff line number Diff line change
1
+ FUTURE
2
+ main.c
3
+ --verify --recursive-interprocedural --call-stack 10 --constants --one-domain-per-history
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^\[main.assertion.1\] .* assertion res == 15: SUCCESS$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ This should be possible just tracking constants and calling stacks.
11
+ At the moment the --constants domain can't do it due to the way it proactively merges to handle recursion.
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ int step (int x )
4
+ {
5
+ if (x == 0 )
6
+ {
7
+ assert (x == 0 );
8
+ return 0 ;
9
+ }
10
+ else
11
+ {
12
+ return step (x - 1 );
13
+ }
14
+ }
15
+
16
+ int main (int argc , char * * argv )
17
+ {
18
+ int orig = 20 ;
19
+ int res = step (orig );
20
+
21
+ assert (res == 0 );
22
+
23
+ return 0 ;
24
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --verify --recursive-interprocedural --call-stack 10 --constants --one-domain-per-history
4
+ ^\[main.assertion.1\] .* assertion res == 0: SUCCESS$
5
+ ^\[step.assertion.1\] .* assertion x == 0: SUCCESS$
6
+ ^EXIT=0$
7
+ ^SIGNAL=0$
8
+ --
9
+ ^warning: ignoring
10
+ --
11
+ Tests the interaction of call stacks and recursion.
12
+
You can’t perform that action at this time.
0 commit comments