andykaylor wrote:

> On a C level, what is the expected behaviour when you cast a function pointer 
> declared as taking no parameters void f(void) to one taking one int param and 
> call it?

I'm pretty sure that's undefined behavior. In general, the compiler tolerates a 
lot of things like this because a lot of old C code plays very fast and loose 
with pointers, and code like that in your example, while technically undefined, 
is often expected to work (in whatever way it always has).

It appears that clang has decided to be more tolerant of this than GCC, though 
you can get a warning for it if you explicitly add `-Wcast-function-type`.

https://github.com/llvm/llvm-project/pull/154060
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to