In this section:
Overview
This error is generated when an attempt is made to call a function through either an invalid or unknown function pointer. Function pointer is not a functionCode Description Enabled Reported Platform FUNC_BAD Runtime Windows/Unix
Problem
A simple way to generate this error is through the use of the union
data type. If the union contains a function pointer which is invoked after initializing some other union member, this error can occur.
/* * File: funcbad.c */ union { int *iptr; int (*fptr)(); } u; main() { int i; u.iptr = &i; u.fptr(); return (0); }
Diagnosis at Runtime
[funcbad.c:14] **FUNC_BAD** >> u.fptr(); Function pointer is not a function: u.fptr Pointer : 0xf7fff8cc In block : 0xf7fff8cc thru 0xf7fff8cf (4 bytes,1 element) i, declared at funcbad.c, 11 Stack trace where the error occurred: main() funcbad.c, 14 **Memory corrupted. Program may crash!!**
- Line 2: Source line at which the problem was detected.
- Line 3: Description of the problem and the expression that is in error.
- Line 4: The value of the pointer through which the call is being attempted.
- Line 6: Description of the memory block to which this pointer actually points, including its size and the source line of its declaration.
- Line 9: Stack trace showing the function call sequence leading to the error.
- Line 10: Informational message indicating that a serious error has occurred which may cause the program to crash.
Repair
The description of the memory block to which the pointer points should enable you to identify the statement which was used to assign the function pointer incorrectly.