File tree 3 files changed +46
-0
lines changed
regression/cbmc/Function_Pointer18
3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ // f is set to 0 -> does not point to either f1 or f2
2
+ #include <assert.h>
3
+
4
+ typedef int (* f_ptr )(int );
5
+
6
+ extern f_ptr f ;
7
+
8
+ int f1 (int j );
9
+ int f2 (int i );
10
+
11
+ int f1 (int j )
12
+ {
13
+ f = & f2 ;
14
+ return 1 ;
15
+ }
16
+ int f2 (int i )
17
+ {
18
+ assert (0 );
19
+ return 2 ;
20
+ }
21
+
22
+ f_ptr f = 0 ;
23
+
24
+ int main ()
25
+ {
26
+ int x = 0 ;
27
+
28
+ x = f (x );
29
+ assert (x == 1 );
30
+ x = f (x );
31
+ assert (x == 2 );
32
+
33
+ return 0 ;
34
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ \[f2.assertion.1\] line [0-9]+ assertion 0: SUCCESS
7
+ \[main.assertion.1\] line [0-9]+ assertion x == 1: SUCCESS
8
+ \[main.assertion.2\] line [0-9]+ assertion x == 2: SUCCESS
9
+ ^VERIFICATION SUCCESSFUL$
10
+ --
11
+ ^warning: ignoring
Original file line number Diff line number Diff line change @@ -416,6 +416,7 @@ void remove_function_pointerst::remove_function_pointer(
416
416
t->source_location .set_property_class (" pointer dereference" );
417
417
t->source_location .set_comment (" invalid function pointer" );
418
418
}
419
+ new_code_gotos.add (goto_programt::make_assumption (false_exprt ()));
419
420
420
421
goto_programt new_code;
421
422
You can’t perform that action at this time.
0 commit comments