void wrong_arguments_func_pointer_011 () { wrong_arguments_func_pointer_011_s_001 st; st.a = 10; char *i="STRING BUFFER"; void (*fptr)(char*); fptr = (void (*)(char*))wrong_arguments_func_pointer_011_func_001; fptr(i);/*Tool should detect this line as error*//*ERROR:Wrong arguments passed to a function pointer*/ void (*fptr1)(wrong_arguments_func_pointer_011_s_001*); fptr1 = wrong_arguments_func_pointer_011_func_002; fptr1(&st); fptr1 = wrong_arguments_func_pointer_011_func_003; fptr1(&st); }
int main() { //int (*fptr)(int, int)=NULL; int (*fptr1)(int, int, int(*)(int, int))=NULL; int m; fptr1 = &find_max_min; m = fptr1(10,20,max); printf("\n%d\n", m); // fptr = &min; // m = fptr(10,20); // printf("\n%d\n", m); return 0; }
void wrong_arguments_func_pointer_012 () { wrong_arguments_func_pointer_012_s_001 st,*st1; st1 = (wrong_arguments_func_pointer_012_s_001 *)malloc(1*sizeof(wrong_arguments_func_pointer_012_s_001)); st.a = 10; char *i="STRING BUFFER"; void (*fptr)(char*); fptr = (void (*)(char*))wrong_arguments_func_pointer_012_func_001; fptr(i);/*Tool should detect this line as error*//*ERROR:Wrong arguments passed to a function pointer*/ void (*fptr1)(wrong_arguments_func_pointer_012_s_001,wrong_arguments_func_pointer_012_s_001 *); fptr1 = wrong_arguments_func_pointer_012_func_002; fptr1(st,st1); void (*fptr2)(wrong_arguments_func_pointer_012_s_001 *,int); fptr2 = wrong_arguments_func_pointer_012_func_003; fptr2(&st,1); }
void func_pointer_011 () { int j; const char buf[][25]={"This is a String", "Second String"}; for(j = 0; j <= 1; j++) { if (MAX ==10) { int (*fptr)(const char *); float *(*fptr1)(const char *); fptr = (int (*)( const char *))func_pointer_011_func_001; fptr1 = (float * (*)( const char *))fptr; fptr1(buf[j]);/*Tool should detect this line as error*/ /*ERROR:Bad function pointer casting*/ } } }