http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46076
--- Comment #17 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-01-11 15:28:56 UTC --- On Tue, 11 Jan 2011, rguenth at gcc dot gnu.org wrote: > I don't think we should add hacks like that. Either the type signatures > are compatible for the middle-end (and exchanging one for the other does not > affect generated code for any target) or not. I can't answer this question. > If they are indeed compatible then fixing the bug is easy. > > Thus, can I call > > void foo(); > > via > > *(void (*)(void))&foo > > and can I call > > void foo (void); > > via > > *(void (*)())&foo > > on all targets without unexpected effects (assuming foo does not use > any arguments)? Yes, those types are compatible and so this should work for all ABIs designed for C (which should mean all ABIs GCC handles). An unprototyped function type is compatible with a prototyped one if the return types are compatible, the prototyped type is not variadic and the prototyped type does not have parameter types such as "char" that are changed under the default argument promotions.