In the following code, foo, bar and baz are used as function pointers in funclist initialization.
#include <stdio.h>
typedef int (Func)();
int foo(void) { printf("foo"); };
int bar(void) { printf("bar"); };
int baz(void) { printf("baz"); };
Func *funclist [] = { foo, bar, baz };
int main(void) {
printf("baz");
baz();
(funclist[2])();
return 1;
}
This simple semantic patch will correctly update the call to baz in main but not in funclist initilization.
The call (funclist[2])() will thus become incorrect.
@@ @@ - baz() + buh()
A even simplier semantic patch that will perform the right transformation is as follows.
@@ - baz + buh