-
Notifications
You must be signed in to change notification settings - Fork 277
Function pointer removal: create fall-back function call #6987
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
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 | ||
^\*\*\*\* WARNING: no body for function main::fptr_call | ||
^\*\*\*\* WARNING: no body for function main::fptr_call\$0 | ||
\[f2.assertion.1\] line [0-9]+ assertion 0: FAILURE | ||
\[main.assertion.1\] line [0-9]+ assertion x == 1: FAILURE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also doesn't make sense, why does one of these fail but not the other? |
||
\[main.assertion.2\] line [0-9]+ assertion x == 2: SUCCESS | ||
^VERIFICATION SUCCESSFUL$ | ||
^VERIFICATION FAILED$ | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <assert.h> | ||
|
||
struct PtrWrapper | ||
{ | ||
char *value_c; | ||
}; | ||
|
||
void fn(struct PtrWrapper wrapper) | ||
{ | ||
assert(wrapper.value_c == 'B'); | ||
} | ||
|
||
void indirect(int (*fn_ptr)(char *), char *data) | ||
{ | ||
fn_ptr(data); | ||
assert(0); | ||
} | ||
|
||
int main() | ||
{ | ||
struct PtrWrapper wrapper; | ||
wrapper.value_c = 'A'; | ||
|
||
int (*alias)(char *) = (int (*)(char *))fn; | ||
indirect(alias, &wrapper.value_c); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CORE | ||
main.c | ||
|
||
^\*\*\*\* WARNING: no body for function indirect::fptr_call | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get why there is a warning in this context? There is only a single thing that |
||
^\[indirect.assertion.1\] line 16 assertion 0: FAILURE$ | ||
^VERIFICATION FAILED$ | ||
^EXIT=10$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,7 @@ typedef int (*other_function_type)(int n); | |
|
||
void foo(other_function_type other_function) | ||
{ | ||
// returning from the function call is unreachable -> the following assertion | ||
// should succeed | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So there is a semantic change for cases where function pointers are invalid / |
||
// requesting `pointer-check` will then catch the fact that there is no valid | ||
// requesting `pointer-check` will catch the fact that there is no valid | ||
// candidate function to call resulting in an invalid function pointer | ||
// failure | ||
assert(other_function(4) > 5); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ main.c | |
^main::1::fun1 \(\) -> value-set-begin: ptr ->\(f\) :value-set-end | ||
^main::1::fun2_show \(\) -> value-set-begin: ptr ->\(f\), ptr ->\(g\) :value-set-end | ||
^main::1::fun3_show \(\) -> value-set-begin: ptr ->\(f\), ptr ->\(g\) :value-set-end | ||
^fun_global_show \(\) -> value-set-begin: ptr ->\(f\), ptr ->\(g\) :value-set-end | ||
^fun_global_show \(\) -> value-set-begin: TOP :value-set-end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the test case this is slightly concerning as |
||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ test.c | |
^SIGNAL=0$ | ||
^file test.c line 20 function main: replacing function pointer by 2 possible targets$ | ||
-- | ||
-- | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
This test checks that the value-set-fi-based function pointer removal | ||
precisely identifies the function to call for a particular function pointer | ||
call. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this now a failure? If I have read the right test case, there is no way
f
can be set tof2
, so the assert inf2
cannot be reachable?