C++ Undefined Behavior Function call through mismatched function pointer type


Example

In order to call a function through a function pointer, the function pointer's type must exactly match the function's type. Otherwise, the behaviour is undefined. Example:

int f();
void (*p)() = reinterpret_cast<void(*)()>(f);
p(); // undefined