Skip to content

Default fall-through for function pointer removal #4646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions regression/cbmc/Function_Pointer18/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// f is set to 0 -> does not point to either f1 or f2
#include <assert.h>

typedef int (*f_ptr)(int);

extern f_ptr f;

int f1(int j);
int f2(int i);

int f1(int j)
{
f = &f2;
return 1;
}
int f2(int i)
{
assert(0);
return 2;
}

f_ptr f = 0;

int main()
{
int x = 0;

x = f(x);
assert(x == 1);
x = f(x);
assert(x == 2);

return 0;
}
11 changes: 11 additions & 0 deletions regression/cbmc/Function_Pointer18/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c

^EXIT=0$
^SIGNAL=0$
\[f2.assertion.1\] line [0-9]+ assertion 0: SUCCESS
\[main.assertion.1\] line [0-9]+ assertion x == 1: SUCCESS
\[main.assertion.2\] line [0-9]+ assertion x == 2: SUCCESS
^VERIFICATION SUCCESSFUL$
--
^warning: ignoring
1 change: 1 addition & 0 deletions src/goto-programs/remove_function_pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ void remove_function_pointerst::remove_function_pointer(
t->source_location.set_property_class("pointer dereference");
t->source_location.set_comment("invalid function pointer");
}
new_code_gotos.add(goto_programt::make_assumption(false_exprt()));

goto_programt new_code;

Expand Down