| > This construct works perfectly fine in C Intuitively, I would say that this is actually undefined behavior (it would probably be difficult to expose a wrong behavior in practice though). In C specs, I found 6.5.2.2, paragraph 9: > If the function is defined with a type that is not compatible with the type (of the expression) pointed to by the expression that denotes the called function, the behavior is undefined. We might discuss whether void (*)(char *)
is "compatible" with void (*)(void *)
but I think it isn't, since: void target(void *ptr) {}
void (*name)(char *ptr) = target;
fails to compile with the error message: initialization of ‘void (*)(void *)’ from incompatible pointer type ‘void (*)(char *)’
The compiler explicitly says "incompatible pointer type".Same for: void target(char *ptr) {}
void (*name)(void *ptr) = target;
|
Emscripten breaks if you cast function pointers: https://emscripten.org/docs/porting/guidelines/function_poin...