https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77392
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- More to the point if do the following casts GCC would have errored out: (void*)send_message (void*)&thread_retval Since you have the cast and in C, void* has an implicit cast to any other pointer type, GCC does not error out. I suspect you added those cast to allow the code to be accepted in the first place and that is wrong.